diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
index 1d526a16..919434a6 100644
--- a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+++ b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -2,6 +2,6 @@
+ location = "self:">
diff --git a/lib/src/chips_input.dart b/lib/src/chips_input.dart
index 43f5bf87..9d90aaa3 100644
--- a/lib/src/chips_input.dart
+++ b/lib/src/chips_input.dart
@@ -349,17 +349,11 @@ class ChipsInputState extends State>
"${replaceText ? '' : _value.normalCharactersText}" +
putText;
setState(() {
- final textLength = updatedText.characters.length;
- final replacedLength = _chips.length;
+ final textLength = updatedText.length;
_value = _value.copyWith(
text: updatedText,
selection: TextSelection.collapsed(offset: textLength),
- composing: (Platform.isIOS || replacedLength == textLength)
- ? TextRange.empty
- : TextRange(
- start: replacedLength,
- end: textLength,
- ),
+ composing: TextRange.empty,
);
});
_textInputConnection ??= TextInput.attach(this, textInputConfiguration);
@@ -449,38 +443,51 @@ class ChipsInputState extends State>
),
);
- return NotificationListener(
- onNotification: (SizeChangedLayoutNotification val) {
- WidgetsBinding.instance?.addPostFrameCallback((_) async {
- _suggestionsBoxController.overlayEntry?.markNeedsBuild();
- });
- return true;
+ 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 - 1);
+ updateEditingValue(TextEditingValue(
+ text: sd, selection: TextSelection.collapsed(offset: sd.length)));
+ }
},
- child: SizeChangedLayoutNotifier(
- child: Column(
- children: [
- 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,
+ child: NotificationListener(
+ onNotification: (SizeChangedLayoutNotification val) {
+ WidgetsBinding.instance?.addPostFrameCallback((_) async {
+ _suggestionsBoxController.overlayEntry?.markNeedsBuild();
+ });
+ return true;
+ },
+ child: SizeChangedLayoutNotifier(
+ child: Column(
+ children: [
+ 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(),
- ),
- ],
+ CompositedTransformTarget(
+ link: _layerLink,
+ child: Container(),
+ ),
+ ],
+ ),
),
),
);