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

Feat: UserExceptionDialog using ScaffoldMessengaer #146

Open
SunlightBro opened this issue Feb 27, 2023 · 2 comments
Open

Feat: UserExceptionDialog using ScaffoldMessengaer #146

SunlightBro opened this issue Feb 27, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@SunlightBro
Copy link
Contributor

SunlightBro commented Feb 27, 2023

UserExceptionDialog was written before flutter had Navigator 2.0 and the new scaffold-messenger

At the moment it still requires to place a UserExceptionDialog<St> in between the MaterialApp and the HomePage Widget, which makes it hard to work with MaterialApp.router.

If possible the best case would be, to not require a UserExceptionDialog Widget at all
and instead directly use the ScaffoldMessenger to display the UserException with a SnackBar.
But this would be a breaking change, so let me know if this is something you want.

@marcglasberg
Copy link
Owner

I have no experience with Navigator 2.0. Is there a way to make what you propose without a breaking change? So that both Navigator 1 and 2 users could be happy with it?

@marcglasberg marcglasberg added the enhancement New feature or request label Feb 27, 2023
@kuhnroyal
Copy link
Contributor

You can just use the getAndRemoveFirstError() function.
For example in a view model as Event(getAndRemoveFirstError()) and then consume it in some widgets didUpdateWidget function or in a StoreConnector.onDidChange.

In the end you just need to map the event/error into a call to ScaffoldMessenger.of(context).showSnackBar and make sure you consume the event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants