0

When there is content in TextField, if tap the TextField, keyboard will shows up, and that's OK. But when dimiss the keyboard by pressing back button or dismissing button in keyboard, keyboard will be hidden, and then shows up again automatically.

Flutter Version: 1.22.5
Dart Version: 2.10.4
Cellphone: xiaomi 8(Android 10)

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
            SizedBox(height: 80),
            TextField(
              onChanged: (value){
                print('$value');
              },
            )
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

enter image description here

R.h
  • 60
  • 8
  • This code don't have issue, Update your flutter version or check on other devices – Xuuan Thuc May 20 '22 at 03:32
  • add textInputAction: TextInputAction.done to your textfield – anggadaz May 20 '22 at 04:25
  • @SaitohAkira It works fine after upgrade flutter verison to 2.10.3, but sadly, I'm working with an obsolete project, upgrading flutter version may costs too much. – R.h May 20 '22 at 06:34
  • @anggadaz Adding textInputAction: TextInputAction.done to textfield not working. – R.h May 20 '22 at 06:36
  • @R.h you can use two versions at the same time. refer https://stackoverflow.com/questions/55783494/how-to-use-two-version-of-flutter-on-same-device-for-different-projects – Xuuan Thuc May 20 '22 at 06:37
  • @SaitohAkira I mean that I meet this issue in the obsolete project I'm working with, which using flutter version 1.22.5. I will try to listen keyboard dimissing, and unfocus. – R.h May 20 '22 at 06:57

0 Answers0