Search code examples
iosfluttersafariflutter-web

Space bar not working for a TextField in iPhone(Safari as well as Chrome) in Flutter Webapp


I have a Flutter Web app deployed on Firebase.

On AndroidPhone/Laptop/Macbook everything is working fine whether it may be on Safari or Chrome.

But on iOS, the space button does nothing when inputting text in a TextField.

The issue is pretty similar to Flutter #79082, but this time it's on iPhone(iOS) only!

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 2.3.0-13.0.pre.73, on Microsoft Windows [Version 10.0.19042.985], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 4.2.0)
[√] VS Code (version 1.56.2)
[√] Connected device (2 available)

• No issues found!

Solution

  • Manually setting keyboard shortcut for Space key worked for me!

    In your main.dart paste the following line of code inside MaterialApp

    shortcuts: {
        LogicalKeySet(LogicalKeyboardKey.space): ActivateIntent(),
     },
    

    Your main.dart should look like:

    Widget build(BuildContext context) {
     return MaterialApp(
       shortcuts: {
         LogicalKeySet(LogicalKeyboardKey.space): ActivateIntent(),
       },
       title: 'title of your app',
       //....
     );
    }