From a9944931995370ae7512a76248d601b10a30a1d1 Mon Sep 17 00:00:00 2001 From: fuwa Date: Mon, 29 Jul 2019 21:25:01 +0800 Subject: [PATCH] keep focus even if input is empty --- cyberwow/lib/widget/synced.dart | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cyberwow/lib/widget/synced.dart b/cyberwow/lib/widget/synced.dart index 414565f..458b2bb 100644 --- a/cyberwow/lib/widget/synced.dart +++ b/cyberwow/lib/widget/synced.dart @@ -150,10 +150,9 @@ Widget terminalView(BuildContext context, String title, SyncedState state) { final input = TextFormField ( controller: state.textController, - textInputAction: TextInputAction.done, + textInputAction: TextInputAction.next, autofocus: true, autocorrect: false, - focusNode: state.focusNode, decoration: InputDecoration ( @@ -171,12 +170,16 @@ Widget terminalView(BuildContext context, String title, SyncedState state) { border: InputBorder.none, ), onFieldSubmitted: (v) { - if (state.textController.text != '') { - FocusScope.of(context).requestFocus(state.focusNode); - log.finer('terminal input: ${state.textController.text}'); - state.appendInput(state.textController.text); + final line = state.textController.text.trim(); + if (line.isNotEmpty) { + log.finer('terminal input: ${line}'); + state.appendInput(line); state.textController.clear(); } + else { + state.textController.clear(); + SystemChannels.textInput.invokeMethod('TextInput.hide'); + } }, );