Skip to content

Commit fc3589a

Browse files
committed
Merge branch 'master' into unstable
# Conflicts: # CHANGELOG.md # pubspec.yaml
2 parents 09a2d83 + 7616cdb commit fc3589a

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [1.9.0-dev.3] - 15-Jun-2020
2+
* Added fixes from v1.8.3
3+
4+
## [1.8.3] - 15-Jun-2020
5+
* Fixed bug in checking whether `maxChips` has been reached.
6+
* Fix `setState called on disposed widget`
7+
18
## [1.9.0-dev.2] - 14-Jun-2020
29
* Merged in changes from v1.8.2
310

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Flutter library for building input fields with InputChips as input options.
77
### Installation
88
Follow installation instructions [here](https://pub.dartlang.org/packages/flutter_chips_input#-installing-tab-)
99

10+
**NOTE:** For anyone on pre-release Flutter channels, kindly prefer the [pre-release versions of the package](https://pub.dev/packages/flutter_chips_input/versions#prerelease).
11+
1012
### Import
1113
```dart
1214
import 'package:flutter_chips_input/flutter_chips_input.dart';

example/lib/main.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ class _MyHomePageState extends State<MyHomePage> {
7171
TextField(),
7272
ChipsInput(
7373
key: _chipKey,
74-
initialValue: [
74+
/*initialValue: [
7575
AppProfile('John Doe', '[email protected]',
7676
'https://d2gg9evh47fn9z.cloudfront.net/800px_COLOURBOX4057996.jpg'),
77-
],
77+
],*/
7878
// autofocus: true,
7979
// allowChipEditing: true,
8080
keyboardAppearance: Brightness.dark,

lib/src/chips_input.dart

+14-10
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
113113
_textInputConnection != null && _textInputConnection.attached;
114114

115115
bool get _hasReachedMaxChips =>
116-
(widget.maxChips != null && _chips.length < widget.maxChips);
116+
widget.maxChips != null && _chips.length >= widget.maxChips;
117117

118118
FocusAttachment _focusAttachment;
119119
FocusNode _focusNode;
@@ -153,9 +153,11 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
153153
_closeInputConnectionIfNeeded();
154154
_suggestionsBoxController.close();
155155
}
156-
setState(() {
157-
/*rebuild so that _TextCursor is hidden.*/
158-
});
156+
if (mounted) {
157+
setState(() {
158+
/*rebuild so that _TextCursor is hidden.*/
159+
});
160+
}
159161
}
160162

161163
void _initOverlayEntry() {
@@ -229,17 +231,19 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
229231

230232
void selectSuggestion(T data) {
231233
if (!_hasReachedMaxChips) {
234+
_chips.add(data);
232235
if (widget.allowChipEditing) {
233236
var enteredText = _value.normalCharactersText ?? '';
234237
if (enteredText.isNotEmpty) _enteredTexts[data] = enteredText;
235238
}
236-
_chips.add(data);
237239
_updateTextInputState(replaceText: true);
240+
238241
_suggestions = null;
239242
_suggestionsStreamController.add(_suggestions);
240243
if (widget.maxChips == _chips.length) _suggestionsBoxController.close();
241-
} else
244+
} else {
242245
_suggestionsBoxController.close();
246+
}
243247
widget.onChanged(_chips.toList(growable: false));
244248
}
245249

@@ -271,9 +275,8 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
271275
final localId = ++_searchId;
272276
final results = await widget.findSuggestions(value);
273277
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);
277280
}
278281
_suggestionsStreamController.add(_suggestions);
279282
}
@@ -325,6 +328,7 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
325328
//composing: TextRange(start: 0, end: text.length),
326329
);
327330
});
331+
print(_value);
328332

329333
if (_textInputConnection == null) {
330334
_textInputConnection = TextInput.attach(this, textInputConfiguration);
@@ -410,7 +414,7 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
410414
maxLines: 1,
411415
overflow: widget.textOverflow,
412416
style: widget.textStyle ??
413-
theme.textTheme.subhead.copyWith(height: 1.5),
417+
theme.textTheme.subtitle1.copyWith(height: 1.5),
414418
),
415419
),
416420
Flexible(

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_chips_input
22
description: Flutter library for building input fields with InputChips as input options.
3-
version: 1.9.0-dev.2
3+
version: 1.9.0-dev.3
44
homepage: https://github.com/danvick/flutter_chips_input
55

66
environment:

0 commit comments

Comments
 (0)