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

[FormBuilderImagePicker] onChanged never triggered #366

Closed
gilthonweapps opened this issue Jul 15, 2020 · 4 comments
Closed

[FormBuilderImagePicker] onChanged never triggered #366

gilthonweapps opened this issue Jul 15, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@gilthonweapps
Copy link

Hi,

It looks like the onChanged method is never triggered. I don't see anything in the code that calls it.
I need to be able to retrieve the selected images in the onChanged.

Regards,

@Jandries
Copy link

Jandries commented Jul 15, 2020

Hi,

I also need this and saw this is not implemented. I think the fix is simple with two places to update in form_builder_image_picker.dart:

InkWell(
   onTap: () {
      var newVal = [...field.value]..remove(item);      //Add this line (about line 158)
      field.didChange(newVal);                          //Change this line (about line 158)
      widget.onChanged?.call(newVal);                   //Add this line (about line 158)
   },
...
onImageSelected: (image) {
   var newVal = [...field.value, image];                //Add this line 207
   field.didChange(newVal);                             //Change this line 207
   Navigator.of(context).pop();
   widget.onChanged?.call(newVal);                      //Add this line 207
},

thanks
Jandries

@gilthonweapps
Copy link
Author

Hi,

Here is what I did:

InkWell(
                              onTap: () {
                                field.didChange([...field.value]..remove(item));
                                widget.onChanged?.call(field.value);
                              },
onImageSelected: (image) {
                                  field.didChange([...field.value, image]);
                                  widget.onChanged?.call(field.value);
                                  Navigator.of(context).pop();
                                },

@Jandries
Copy link

I think that will still give you the old value in onChanged() Or does it work correctly that way?

@danvick
Copy link
Collaborator

danvick commented Jul 16, 2020

That'll also work.

@danvick danvick added the bug Something isn't working label Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants