Reputation:
Please take a look at the following Flutter code snippet: it creates a TextField
that is intended as a single line input field tat will submit 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();
});
})),
On the iOS Simulator the corresponding app looks as follows:
As you can see the widget is configured with maxLines = 1
, but when I click the Return key on the onscreen keyboard, line feeds are insert. Please spot the narrow blue cursor a couple of lines below the widget. Also, I see no console output, which should be the case because of my onSubmitted()
lambda.
Am I configuring the text field correctly, or am I missing something?
Upvotes: 9
Views: 11944
Reputation: 116828
This looks to me like it's actually just a bug in the iOS version of Flutter. Filed issue #9839.
Upvotes: 2