Skip to content

Commit d785b69

Browse files
committed
Fixed bug where initialValue in TextEditingController ignored in Typeahead
1 parent 796b41e commit d785b69

File tree

6 files changed

+26
-28
lines changed

6 files changed

+26
-28
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [3.12.0] - 24-Jul-2020
2+
* Added new field `FormBuilderCheckboxGroup`. Closes #188
3+
* Removed `group_radio_button` library dependency, made own implementation with label fix. Closes #376, #335
4+
* Add web support for ImagePicker. Courtesy of [vin-fandemand](https://github.com/vin-fandemand)
5+
* Fixed bug where value within `TextEditingController` ignored in `FormBuilderTypeahead`
6+
17
## [3.11.6] - 20-Jul-2020
28
* Upgraded dependencies
39
* Fixed error '`The getter 'initialValue' was called on null`' if no `FormBuilderState` ancestry. Closes #364

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ class MyHomePageState extends State<MyHomePage> {
308308
);
309309
},
310310
controller: TextEditingController(text: ''),
311-
initialValue: 'Uganda',
311+
initialValue: 'Kenya',
312312
suggestionsCallback: (query) {
313313
if (query.isNotEmpty) {
314314
var lowercaseQuery = query.toLowerCase();

lib/src/fields/form_builder_typeahead.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class _FormBuilderTypeAheadState<T> extends State<FormBuilderTypeAhead<T>> {
105105
: widget.textFieldConfiguration.focusNode;
106106

107107
_initialValue = widget.initialValue ??
108+
_typeAheadController.text ??
108109
(_formState.initialValue.containsKey(widget.attribute)
109110
? _formState.initialValue[widget.attribute]
110111
: null);
@@ -198,14 +199,6 @@ class _FormBuilderTypeAheadState<T> extends State<FormBuilderTypeAhead<T>> {
198199
@override
199200
void dispose() {
200201
_formState?.unregisterFieldKey(widget.attribute);
201-
/*if (widget.controller == null) {
202-
_typeAheadController?.dispose();
203-
} else {
204-
_typeAheadController?.removeListener(_handleStringOnChanged);
205-
}
206-
if (widget.textFieldConfiguration.focusNode == null) {
207-
_typeAheadFocusNode?.dispose();
208-
}*/
209202
super.dispose();
210203
}
211204
}

lib/src/widgets/grouped_checkbox.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -267,30 +267,30 @@ class _GroupedCheckboxState<T> extends State<GroupedCheckbox<T>> {
267267
value: selectedListItems.contains(widget.options[index].value),
268268
tristate: widget.tristate,
269269
onChanged: (widget.disabled != null &&
270-
widget.disabled.contains(widget.options.elementAt(index).value))
270+
widget.disabled.contains(widget.options.elementAt(index).value))
271271
? null
272272
: (bool selected) {
273-
selected
274-
? selectedListItems.add(widget.options[index].value)
275-
: selectedListItems.remove(widget.options[index].value);
276-
setState(() {
277-
widget.onChanged(selectedListItems);
278-
});
279-
},
273+
selected
274+
? selectedListItems.add(widget.options[index].value)
275+
: selectedListItems.remove(widget.options[index].value);
276+
setState(() {
277+
widget.onChanged(selectedListItems);
278+
});
279+
},
280280
);
281281
var label = GestureDetector(
282282
child: widget.options[index],
283283
onTap: (widget.disabled != null &&
284-
widget.disabled.contains(widget.options.elementAt(index).value))
284+
widget.disabled.contains(widget.options.elementAt(index).value))
285285
? null
286286
: () {
287-
!selectedListItems.contains(widget.options[index].value)
288-
? selectedListItems.add(widget.options[index].value)
289-
: selectedListItems.remove(widget.options[index].value);
290-
setState(() {
291-
widget.onChanged(selectedListItems);
292-
});
293-
},
287+
!selectedListItems.contains(widget.options[index].value)
288+
? selectedListItems.add(widget.options[index].value)
289+
: selectedListItems.remove(widget.options[index].value);
290+
setState(() {
291+
widget.onChanged(selectedListItems);
292+
});
293+
},
294294
);
295295

296296
return Row(

lib/src/widgets/grouped_radio.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,3 @@ class _GroupedRadioState<T> extends State<GroupedRadio<T>> {
300300
}
301301

302302
enum GroupedRadioOrientation { horizontal, vertical, wrap }
303-

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_form_builder
22
description: Package to build Material Form with fields like TextField, DropDown, Switches etc. with ability to create custom FormFields and composability and reuse validation functions.
3-
version: 3.11.6
3+
version: 3.12.0
44
homepage: https://github.com/danvick/flutter_form_builder
55

66
environment:
@@ -28,7 +28,7 @@ dependencies:
2828
dev_dependencies:
2929
flutter_test:
3030
sdk: flutter
31-
test: ^1.14.4
31+
test:
3232
pedantic: ^1.9.0
3333

3434
flutter:

0 commit comments

Comments
 (0)