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
Added error and stack trace parameters to onError #35
base: main
Are you sure you want to change the base?
Added error and stack trace parameters to onError #35
Conversation
Man, I was not paying attention when I added that callback. Good catch ! I think there might already be a flutter typedef that is |
Currently our callbacks (onSuccess, onError) fire at the end of the errorDuration/successDuration so they might mislead the user to think they'll fire as soon as an error is encountered. I'm not sure when I added these callbacks but I think they should be renamed to onSuccessCompleted or onErrorShown etc to show they're at the end of error/loading state. For immediately telling if it's an error or success, you could do it in the async onPressed no? What are your thoughts on this |
6033d65
to
def3dcf
Compare
I couldn't find a typedef in Flutter itself that defines Do If it helps, I'm using I'll leave it in your hands to think over, but let me know if you want me to make any changes! |
def3dcf
to
623dd7e
Compare
Yeah no worries with the typedef. What you have currently looks good. So I think what is best is to rename the current callbacks we have now to onSuccessShown and onErrorShown. That would show the user those callbacks happen after the specified duration. I imagine these callbacks being used to route users or similar so I think they have utility. After that, we should add back in onError and onSuccess but so that they're immediate. timer?.cancel();
onPressed.call().then((_) {
completer.complete();
onSuccess?.call();
if (mounted) { I think the docs should better reflect how these callbacks are called as well since what I have currently doesn't make sense. If you want to do both the changing and additions in this PR or only the renaming, however is fine. Thank you for the help too ! |
This adds the thrown
error
andstackTrace
parameters to theonError
callback.It's quite useful to have these passed in, so the caller can e.g. show a
SnackBar
with some of the error details.