Reputation:
how to change TextInputAction.newLine
to TextInputAction.done
after Continuous two new line,
i need to exit new line after selected many Continuous new line
Upvotes: 1
Views: 527
Reputation: 4854
One solution would be to use a state variable in a Stateful
Widget:
bool _done = false;
Listen to the edited text:
TextField(
onChanged(s) {
if (s.substring(s.length - 2) == "\n\n") setState(() => _done = true);
else setState(() => _done = false);
}
)
And change the TextInputAction
accordingly:
TextField(
onChanged(s) {
if (s.substring(s.length - 2) == "\n\n") setState(() => _done = true);
else setState(() => _done = false);
},
textInputAction: _done ? TextInputAction.done : TextInputAction.newLine
)
Upvotes: 3