Skip to content

Initial values showing issue #22

Description

@yuri4031

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions