@@ -113,7 +113,7 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
113
113
_textInputConnection != null && _textInputConnection.attached;
114
114
115
115
bool get _hasReachedMaxChips =>
116
- ( widget.maxChips != null && _chips.length < widget.maxChips) ;
116
+ widget.maxChips != null && _chips.length >= widget.maxChips;
117
117
118
118
FocusAttachment _focusAttachment;
119
119
FocusNode _focusNode;
@@ -153,9 +153,11 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
153
153
_closeInputConnectionIfNeeded ();
154
154
_suggestionsBoxController.close ();
155
155
}
156
- setState (() {
157
- /*rebuild so that _TextCursor is hidden.*/
158
- });
156
+ if (mounted) {
157
+ setState (() {
158
+ /*rebuild so that _TextCursor is hidden.*/
159
+ });
160
+ }
159
161
}
160
162
161
163
void _initOverlayEntry () {
@@ -229,17 +231,19 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
229
231
230
232
void selectSuggestion (T data) {
231
233
if (! _hasReachedMaxChips) {
234
+ _chips.add (data);
232
235
if (widget.allowChipEditing) {
233
236
var enteredText = _value.normalCharactersText ?? '' ;
234
237
if (enteredText.isNotEmpty) _enteredTexts[data] = enteredText;
235
238
}
236
- _chips.add (data);
237
239
_updateTextInputState (replaceText: true );
240
+
238
241
_suggestions = null ;
239
242
_suggestionsStreamController.add (_suggestions);
240
243
if (widget.maxChips == _chips.length) _suggestionsBoxController.close ();
241
- } else
244
+ } else {
242
245
_suggestionsBoxController.close ();
246
+ }
243
247
widget.onChanged (_chips.toList (growable: false ));
244
248
}
245
249
@@ -271,9 +275,8 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
271
275
final localId = ++ _searchId;
272
276
final results = await widget.findSuggestions (value);
273
277
if (_searchId == localId && mounted) {
274
- _suggestions = results
275
- .where ((profile) => ! _chips.contains (profile))
276
- .toList (growable: false );
278
+ _suggestions =
279
+ results.where ((r) => ! _chips.contains (r)).toList (growable: false );
277
280
}
278
281
_suggestionsStreamController.add (_suggestions);
279
282
}
@@ -325,6 +328,7 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
325
328
//composing: TextRange(start: 0, end: text.length),
326
329
);
327
330
});
331
+ print (_value);
328
332
329
333
if (_textInputConnection == null ) {
330
334
_textInputConnection = TextInput .attach (this , textInputConfiguration);
@@ -410,7 +414,7 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
410
414
maxLines: 1 ,
411
415
overflow: widget.textOverflow,
412
416
style: widget.textStyle ??
413
- theme.textTheme.subhead .copyWith (height: 1.5 ),
417
+ theme.textTheme.subtitle1 .copyWith (height: 1.5 ),
414
418
),
415
419
),
416
420
Flexible (
0 commit comments