skip to Main Content

There are 2 "Done" buttons when keyboard shows up:

  • When I press on the first Done button, keyboard hides, BUT the TextField still keeps the focusing status.
  • When I press on the second Done button, keyboard hides, and TextField also removes the focusing status.

Seems like the properties onSubmitted() and onEditingComplete() won’t be triggered if I press on the first Done button.

Is there anyway to fix this issue? Or anyway to HIDE the first Done button? Thank you guys.

enter image description here

The source code is very simple:

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: Center(
          child: TextField(
            decoration: InputDecoration(
              hintText: 'Enter your name',
            ),
          ),
        ),
      ),
    );
  }
}

You can edit the launch.json (if you use VSCode) configuration like this:

"configurations": [
        {
            "name": "package_name", // package name
            "request": "launch",
            "type": "dart",
            "args": [
                "--release",
                "--web-hostname",
                "192.168.xxx.xxx", // your IP address
                "--web-port",
                "8080"
            ]
        }
    ]
}

Then, you open your Safari from Simulator and open link: http://192.168.xxx.xxx:8080

enter image description here

2

Answers


  1. It is the normal behavior of iOS. The first "done" button you’re talking about is just a "hide my keyboard" button. It will not do anything else.

    In Flutter you can try to add a "keyboardType" parameters:

    TextField(
                keyboardType: TextInputType.***,
              ),
    

    I can’t try on an iOS as I don’t have one. But try different TextInputType, you may be able to remove this done button.

    More info :
    https://stackoverflow.com/a/75842595/9990911
    https://api.flutter.dev/flutter/services/TextInputType-class.html

    Login or Signup to reply.
  2. you can use Specific FocusNode for the TextField and then after pressing the done button that FocusNode variable set to unfocus.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search