diff --git a/lib/boxes/console.dart b/lib/boxes/console.dart index a21332d..ba980bf 100644 --- a/lib/boxes/console.dart +++ b/lib/boxes/console.dart @@ -117,7 +117,7 @@ class _SerialDetailPageState extends State { serial.sprintln(_textController.text); _messages.add(_textController.text); messageIndex = _messages.length; - _textController.clear(); + _textController.text = ""; }); _textFocus.requestFocus(); } @@ -127,26 +127,28 @@ class _SerialDetailPageState extends State { if (event.runtimeType.toString() == 'RawKeyDownEvent') { if (event.logicalKey == LogicalKeyboardKey.arrowUp) { if (messageIndex > 0) { - setState(() { - messageIndex--; - print("up: " + _messages[messageIndex]); + messageIndex--; + Future.delayed(const Duration(microseconds: 10), () { _textController.text = _messages[messageIndex]; + _textController.selection = + TextSelection.collapsed(offset: _textController.text.length); }); } } else if (event.logicalKey == LogicalKeyboardKey.arrowDown) { if (messageIndex >= _messages.length - 1) { setState(() { - print("clear"); messageIndex = _messages.length; - _textController.clear(); - _textFocus.requestFocus(); + Future.delayed(const Duration(microseconds: 10), () { + _textController.text = ""; + _textController.selection = const TextSelection.collapsed(offset: 0); + }); }); } else { - setState(() { - messageIndex++; - print("down: " + _messages[messageIndex]); + messageIndex++; + Future.delayed(const Duration(microseconds: 10), () { _textController.text = _messages[messageIndex]; - _textFocus.requestFocus(); + _textController.selection = + TextSelection.collapsed(offset: _textController.text.length); }); } }