jeudi 5 août 2021

How to display a snackbar from the backend

I want to display a Snackbar when an error is detected in some function, let it called function C. So my StatefulWidget calls function A, A calls function B, B calls function C and there I have an 'if statement' to decide whether to display the SnackAbar. The trivial solution is to pass the context or globalKey as a parameter through functions A, B and C. and C will use it to display the Snackbar. But this is definitely not a nice solution and I am definitely not the first to face such a dilemma, What is the cleanest and most efficient way to do this?

Thanks

Aucun commentaire:

Enregistrer un commentaire