-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial values showing issue #22
Comments
Having the same issue, no solution so far. |
if (state.value != null) {
state.value.forEach((item) {
var existingItem = dataSource.singleWhere((itm) => itm[valueField] == item, orElse: () => null);
selectedOptions.add(Chip(
label: Text(existingItem[textField], overflow: TextOverflow.ellipsis),
));
});
}
Examplereturn MultiSelectFormField(
title: Text('Barcode Formats'),
dataSource: BarcodeFormat.values.map((barcodeFormat) {
return {'display': barcodeFormat.name, 'value': barcodeFormat.value};
}).toList(),
textField: 'display',
valueField: 'value',
initialValue: List<String>.from(snapshot.data),
onSaved: (values) => persistBarcodeSettings(values: values),
); If both your So in your case @yuri4031, you have to provide a |
@DavidCorrado thanks man |
@vishalpatelbacancy Poor DavidCorrado will be very confused why it is you thanked him xD |
Sorry my bad, @david-kalbermatten thanks man :-) |
I've had a similar problem and the my problem was intialValue comes after a future which is after building the widget
and you must ensure that intialValue is list of the same type as valueField in dataSource as stated by @david-kalbermatten
I encourage the maintainers to add key property to the widget |
@redbayoub thanks mate, |
happy to hear that man. happy coding.
…On Tue, Nov 24, 2020 at 4:28 PM Rouvo ***@***.***> wrote:
@redbayoub <https://github.com/redbayoub> thanks mate, KeyedSubtree did
the magic for me
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#22 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGDF266ES6KWYUXRKVQQNN3SROGW7ANCNFSM4QMGCTHQ>
.
--
Vishal Patel
*- Android developer*
Bacancy Technology Pvt Ltd
p: 079- 40299222
a: 201, Shukan Complex, Above Hind Super Market,
Thaltej shilaj Road Thaltej Ahmedabad-380059
w: www.bacancytechnology.com
e: [email protected]
|
Hi so I'm using this array as my datasource
[{"id":2,"name":"Carpet Furniture Wash"}]
and using
textField: 'name',
valueField: 'id',
if my initialvalues are empty the dialog is working fine and selected values are shown on ok click
but if i set my intialvalues just like the above data source
then I'm getting error on these lines
if (state.value != null) {
state.value.forEach((item) {
var existingItem = dataSource.singleWhere((itm) => itm[valueField] == item, orElse: () => null);
selectedOptions.add(Chip(
label: Text(existingItem[textField], overflow: TextOverflow.ellipsis),
));
});
}
the bold line has an issue where we are comparing a field with object, which i think should be compared with valueField of datasource item.
Can you please look into it?
Here's my stacktrace:
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
2020-08-27 00:38:39.899 10319-10414/com.yallah.arbi I/flutter: The following NoSuchMethodError was thrown building MultiSelectFormField(dirty, dependencies:
2020-08-27 00:38:39.899 10319-10414/com.yallah.arbi I/flutter: [_FormScope], state: FormFieldState#a128f):
2020-08-27 00:38:39.899 10319-10414/com.yallah.arbi I/flutter: The method '[]' was called on null.
2020-08-27 00:38:39.899 10319-10414/com.yallah.arbi I/flutter: Receiver: null
2020-08-27 00:38:39.899 10319-10414/com.yallah.arbi I/flutter: Tried calling:
2020-08-27 00:38:39.900 10319-10414/com.yallah.arbi I/flutter: The relevant error-causing widget was:
2020-08-27 00:38:39.900 10319-10414/com.yallah.arbi I/flutter: MultiSelectFormField
2020-08-27 00:38:39.900 10319-10414/com.yallah.arbi I/flutter: file:///Volumes/Stuff/Dev/Mine/Flutter/yalla/lib/ui/provider/provider_profile.dart:415:12
2020-08-27 00:38:39.900 10319-10414/com.yallah.arbi I/flutter: When the exception was thrown, this was the stack:
2020-08-27 00:38:39.900 10319-10414/com.yallah.arbi I/flutter: #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
2020-08-27 00:38:39.900 10319-10414/com.yallah.arbi I/flutter: #1 new MultiSelectFormField.._buildSelectedOptions. (package:multiselect_formfield/multiselect_formfield.dart:58:45)
2020-08-27 00:38:39.900 10319-10414/com.yallah.arbi I/flutter: #2 List.forEach (dart:core-patch/growable_array.dart:289:8)
2020-08-27 00:38:39.900 10319-10414/com.yallah.arbi I/flutter: #3 new MultiSelectFormField.._buildSelectedOptions (package:multiselect_formfield/multiselect_formfield.dart:55:29)
2020-08-27 00:38:39.900 10319-10414/com.yallah.arbi I/flutter: #4 new MultiSelectFormField. (package:multiselect_formfield/multiselect_formfield.dart:140:60)
2020-08-27 00:38:39.900 10319-10414/com.yallah.arbi I/flutter: #5 FormFieldState.build (package:flutter/src/widgets/form.dart:439:26)
The text was updated successfully, but these errors were encountered: