From 7a2d687367361ba1924ac68841fd7d6e8b2f05f8 Mon Sep 17 00:00:00 2001 From: open-trade Date: Wed, 25 Nov 2020 20:51:32 +0800 Subject: [PATCH] trick way to make backspace work always --- flutter_hbb/lib/remote_page.dart | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/flutter_hbb/lib/remote_page.dart b/flutter_hbb/lib/remote_page.dart index b98029da6..8b5fcbbea 100644 --- a/flutter_hbb/lib/remote_page.dart +++ b/flutter_hbb/lib/remote_page.dart @@ -68,7 +68,7 @@ class _RemotePageState extends State { var v = MediaQuery.of(context).viewInsets.bottom; if (v != _bottom) { resetTool(); - _value = ''; + _value = ' ' * 1000; setState(() { _bottom = v; if (v < 100) { @@ -222,16 +222,18 @@ class _RemotePageState extends State { height: 0, child: _bottom < 100 ? Container() - : TextField( + : TextFormField( textInputAction: TextInputAction.newline, autocorrect: false, enableSuggestions: false, focusNode: _focusNode, maxLines: null, + initialValue: + _value, // trick way to make backspace work always keyboardType: TextInputType.multiline, onChanged: (x) { var char = x[x.length - 1]; - if (x.length < _value.length) { + if (x.length <= _value.length) { char = 'VK_BACK'; } else if (char == '\n') { char = 'VK_RETURN';