From 768179ab244670e5f765044ad7f5655fb0c58d08 Mon Sep 17 00:00:00 2001 From: jusax23 Date: Mon, 18 Sep 2023 20:25:23 +0200 Subject: [PATCH] console fix --- lib/boxes/console.dart | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) 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); }); } }