Skip to content
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

Runtime error when passing immutable list -> Unsupported operation: Cannot remove / add from an unmodifiable list #62

Open
mqhamdam opened this issue Mar 6, 2024 · 1 comment

Comments

@mqhamdam
Copy link

mqhamdam commented Mar 6, 2024

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?

@mqhamdam
Copy link
Author

mqhamdam commented Mar 6, 2024

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.

@mqhamdam mqhamdam changed the title Unsupported operation: Cannot remove from an unmodifiable list Bug when passing immutable list -> Unsupported operation: Cannot remove / add from an unmodifiable list Mar 6, 2024
@mqhamdam mqhamdam changed the title Bug when passing immutable list -> Unsupported operation: Cannot remove / add from an unmodifiable list Runtime error when passing immutable list -> Unsupported operation: Cannot remove / add from an unmodifiable list Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant