custom-dropdown
custom-dropdown copied to clipboard
Runtime error when passing immutable list -> Unsupported operation: Cannot remove / add from an unmodifiable list
Error occurs using multiSelect
factory
Flexible(
child: CustomDropdown.multiSelectSearch(
key: const Key("PickScanItems-ItemSerials"),
items: itemSerialsList.isEmpty ? [kEmptyList] : itemSerialsList,
onListChanged: _onItemSerialsChange,
hintText: "Select Item Serials",
initialItems: itemSerials.isEmpty ? null : itemSerials,
),
),
itemSerials
and itemSerialsList
are unmodifiable list (using freezed for immutability)
is it possible to refactor remove/add events in immutable way? or is it possible to give developer to handle events by callbacks?
if anyone else have same problem, you could use below example :
Flexible(
child: CustomDropdown.multiSelectSearch(
key: const Key("PickScanItems-ItemSerials"),
items: itemSerialsList.isEmpty
? [kEmptyList]
: List.of(itemSerialsList),
onListChanged: _onItemSerialsChange,
hintText: "Select Item Serials",
initialItems: itemSerials.isEmpty ? null : List.of(itemSerials),
),
),
Basically I'm creating new modifiable list from unmodifiable list.
I keep open the issue cuz i think it would be good to have options for developers to choose and make CustomSearch widget more flexible in use.