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

Changing a value of certain index in ObservableList of tubles makes some issues #1015

Open
WissamALSbenaty opened this issue Sep 6, 2024 · 1 comment

Comments

@WissamALSbenaty
Copy link

I have this example

mixin MultipleImagePickingMixin on BaseController {
  @observable
  ObservableList<(FileDto?,ImageModel?)> images = ObservableList.of([(null,null)]);
  @action
  void increaseImagesCounter() => images.add((null,null));
  @action
  void removeImage({required final int imageIndex}) =>
      imageIndex == 0 && images.length == 1
          ? () {}
          : images.removeAt(imageIndex);
  @action
  void changeImage(
          {required final int index, required final FileDto newImage}) =>
      images[index] = (newImage,null);
}

Where BaseController is a Store

When i try to change an image , an exception is thrown
Unhandled Exception: type '(FileDto, Null)' is not a subtype of type '(Null, Null)' of 'value'

@WissamALSbenaty
Copy link
Author

WissamALSbenaty commented Sep 6, 2024

It turns out that the problem is from using a nullable generic type which is not supported for ObservableList functions like operator [] , add , insert , etc

so if you trying to use ObservableList<Something?> then all functions mentioned above of this instance should use a Something object not Something?

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