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

ReactiveImagePicker: how to make deleteDialogBuilder? #156

Closed
Dionnie123 opened this issue Jul 10, 2024 · 4 comments
Closed

ReactiveImagePicker: how to make deleteDialogBuilder? #156

Dionnie123 opened this issue Jul 10, 2024 · 4 comments

Comments

@Dionnie123
Copy link

Dionnie123 commented Jul 10, 2024

I tried many approach, the image still stays when I confirm delete on dialog.

  deleteDialogBuilder: (context, onConfirm) {
        return showDialog<void>(
          context: context,
          barrierDismissible: false, // User must tap button to dismiss dialog
          builder: (BuildContext dialogContext) {
            return AlertDialog(
              title: const Text('Delete File'),
              content:
                  const Text('Are you sure you want to delete this file?!!'),
              actions: <Widget>[
                TextButton(
                  child: const Text('Cancel'),
                  onPressed: () {
                    Navigator.of(dialogContext).pop(); // Dismiss the dialog
                  },
                ),
                TextButton(
                  child: const Text('Delete'),
                  onPressed: () {
// Call the onDelete callback
                       onConfirm(SelectedFile.image());

                    Navigator.of(dialogContext).pop(); // Dismiss the dialog
                  },
                ),
              ],
            );
          },
        );
      },

image

@Dionnie123
Copy link
Author

Looks like I got it now, I just need to access form control value and give to onConfirm, it works but still not 100% sure.

  TextButton(
                  child: const Text('Delete'),
                  onPressed: () {
                    onConfirm(formControl!.value![0]);
                    Navigator.of(dialogContext).pop(); // Dismiss the dialog
                  },
                ),

@UsamaKarim
Copy link
Contributor

The implementation seems vague, when I call handleDelete it takes SelectedFile parameter, when it's already knows the file then why deleteDialogBuilder asking for file again.

@vasilich6107
Copy link
Contributor

Hey @Dionnie123 try reactive_image_picker 7.0.0
I've fixed the deleteDialogBuilder

Copy link

Hi @Dionnie123!
Your issue has been closed. If we were helpful don't forget to star the repo.

Please check our reactive_forms_generator package

We would appreciate sponsorship subscription or one time donation
https://github.com/sponsors/artflutter

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

3 participants