Replies: 3 comments
-
Changed the title of the question to better reflect the issue. It's quite common for onClick handlers, etc. to make an async call (to add something to a database), and then you want to show the user the status of the call (perhaps using a snackbar). Any suggestions/tricks that avoid the extra boilerplate of a stateful widget? |
Beta Was this translation helpful? Give feedback.
-
ok- this looks relevant: https://stackoverflow.com/questions/69466478/waiting-asynchronously-for-navigator-push-linter-warning-appears-use-build/69512692#69512692 So changing my onClick handler to something like this:
Seems to make the linter happy. |
Beta Was this translation helpful? Give feedback.
-
Also relevant #1331 |
Beta Was this translation helpful? Give feedback.
-
I'm getting the linter warning "DO NOT use BuildContext across asynchronous gaps." from this code within a HookConsumerWidget:
The suggested solution
if (!mounted) return;
only works for StatefulWidgets.I suppose I can convert this to a StatefulHooksConsumer - but I'd like to avoid the additional boilerplate.
Is there a better solution ?
Beta Was this translation helpful? Give feedback.
All reactions