How can I use flutter, how can I call onSubmitted () of TextField on iOS?

Notice the following flutter code snippet: it creates TextField

, which is intended as a one-line input field. tat will send its value when Return is pressed:

child: new TextField(
  decoration: _deco,
  maxLines: 1,
  autofocus: true,
  onSubmitted: (newValue) {print(newValue);},
  onChanged: (newValue) {
    setState(() {
      strTemperature = newValue.trim();
    });
  })),

      

In the iOS Simulator, the corresponding app looks like this:

Screenshot of my sample app

As you can see, the widget is configured with maxLines = 1

, but when I press the Return key on the onscreen keyboard, line feeds are inserted. Point the narrow blue cursor a couple of lines below the widgets. Also, I can't see the console output, which should be because of my onSubmitted()

lambda.

Am I setting up the textbox correctly or is there something missing?

+3


source to share


1 answer


It seems to me that this is just a bug in the iOS version of Flutter. Posted issue # 9839 .



+1


source







All Articles