Created
June 26, 2022 17:48
-
-
Save pawelsa/56cab1ec8ade72291483747c50a881b2 to your computer and use it in GitHub Desktop.
Showing snackbar from the error cause obtained by executing usecase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final loadMoviesResult = await loadPopularMoviesUsecase(); | |
if(result is ErrorResult){ | |
final messenger = (String msg) => ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(msg))); | |
result.errorCause.whenOrNull(error: (cause) { | |
return cause.when( | |
noInternet: () => messenger("Lost connection when loading popular movies"), | |
unknown: () => messenger("Unexpected error happen when loading popular movies"), | |
); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment