Fix backspace bug for android devices#96
Fix backspace bug for android devices#96jorelkimcruz wants to merge 2 commits intodanvick:masterfrom
Conversation
jorelkimcruz
commented
Aug 19, 2021
- Wrapped notificationListener with RawKeyboardListener to fix bug for android devices
- Wrapped notificationListener with RawKeyboardListener to fix bug for android devices
|
also in my case I also have to revert to void _updateTextInputState({bool replaceText = false, String putText = ''}) {
if (replaceText || putText != '') {
final updatedText =
String.fromCharCodes(_chips.map((_) => kObjectReplacementChar)) +
(replaceText ? '' : _value.normalCharactersText) +
putText;
setState(() => _value = _value.copyWith(
text: updatedText,
selection: TextSelection.collapsed(offset: updatedText.length),
//composing: TextRange(start: 0, end: text.length),
composing: TextRange.empty,
));
}
_closeInputConnectionIfNeeded(); //Hack for #34 (https://github.com/danvick/flutter_chips_input/issues/34#issuecomment-684505282). TODO: Find permanent fix
_textInputConnection ??= TextInput.attach(this, textInputConfiguration);
_textInputConnection?.setEditingState(_value);
}but this is not in the PR. |
7d73d1c to
2193b3a
Compare
Updated PR this is what causing the issue. void _updateTextInputState({bool replaceText = false, String putText = ''}) {
if (replaceText || putText != '') {
final updatedText =
String.fromCharCodes(_chips.map((_) => kObjectReplacementChar)) +
(replaceText ? '' : _value.normalCharactersText) +
putText;
setState(() => _value = _value.copyWith(
text: updatedText,
selection: TextSelection.collapsed(offset: updatedText.length),
//composing: TextRange(start: 0, end: text.length),
composing: TextRange.empty,
));
}
_closeInputConnectionIfNeeded(); //Hack for #34 (https://github.com/danvick/flutter_chips_input/issues/34#issuecomment-684505282). TODO: Find permanent fix
_textInputConnection ??= TextInput.attach(this, textInputConfiguration);
_textInputConnection?.setEditingState(_value);
} |
2193b3a to
e73db32
Compare
- remove platform specific checking in composing parameter
e73db32 to
40eb170
Compare
|
@jorelkimcruz Hey, the above commits have fixed the issue but the cursor is not visible. can you fix this? |
have you tried changing the cursors color? |
Is there a way to change the cursor color? I am not able to find any parameter that does this. |
inside text_cursor.dart |
|
@jorelkimcruz, have you tried this on the iOS simulator? I just tried out your branch (per #97 (comment)), and it seems to fix the focus issue, but it has a really strange issue of character repeating. When you type (with a hardware keyboard) into the input in the iOS simulator, sometimes a key that you hit once may be repeated multiple times. I've noticed this both for entering new letters as well as backspacing (where sometimes a single backspace will remove multiple characters). |
Hi, Sorry been busy and didnt got the time to push a fix. but if you need this asap here is a fix. return RawKeyboardListener(
focusNode: _focusNode, // or FocusNode()
onKey: (event) {
final str = currentTextEditingValue.text;
if (event.runtimeType.toString() == 'RawKeyDownEvent' &&
event.logicalKey == LogicalKeyboardKey.backspace &&
str.isNotEmpty) {
final sd = str.substring(0, str.length);
updateEditingValue(TextEditingValue(
text: sd, selection: TextSelection.collapsed(offset: sd.length)));
}
},
child: NotificationListener<SizeChangedLayoutNotification>(
onNotification: (SizeChangedLayoutNotification val) {
WidgetsBinding.instance?.addPostFrameCallback((_) async {
_suggestionsBoxController.overlayEntry?.markNeedsBuild();
});
return true;
},
child: SizeChangedLayoutNotifier(
child: Column(
children: <Widget>[
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
requestKeyboard();
},
child: InputDecorator(
decoration: widget.decoration,
isFocused: _focusNode.hasFocus,
isEmpty: _value.text.isEmpty && _chips.isEmpty,
child: Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
spacing: 4.0,
runSpacing: 4.0,
children: chipsChildren,
),
),
),
CompositedTransformTarget(
link: _layerLink,
child: Container(),
),
],
),
),
),
); |
|
@jorelkimcruz, we're not actively using your branch, so no rush on a fix. The main issue we were trying to work around is with the iOS keyboard disappearing, which I have submitted #99 for. I'll be happy to test out your change again once you push the change onto your branch, too 👍 |