Handling Multiple snack bars Display Issues in Concurrent API Calls. #3151
-
I am encountering an issue with displaying multiple snack bars in quick succession. For example, when I initiate five API calls simultaneously without waiting for their responses, and if any of these APIs fail, I attempt to show snack bars to indicate the errors. However, when multiple snack bars are triggered in rapid succession, the application crashes. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Try using this code:
Explanation: |
Beta Was this translation helpful? Give feedback.
-
Okay, thank you! |
Beta Was this translation helpful? Give feedback.
Try using this code:
Explanation:
The
showSnackbar
function first attempts to close any currently displayed snack bar usingGet.closeCurrentSnackbar()
. Once the current snack bar is closed (as ensured by thewhenComplete
callback), it then displays a new snack bar with the provided title and message. The use ofunawaited
suggests that the function is designed to run independently of the completion of theFuture
fromGet.clos…