Flutter: How can I dismiss a flushbar elsewhere in the code?

Viewed 204

I would like to show a flushbar while something is being stored on my server. I can start it with an infinite duration, but can the flushbar be found elsewhere in the code and dismissed?

1 Answers

I suspect you can, despite not knowing the package and by checking the source code you can assign it a GlobalKey and then call its methods through it.

final GlobalKey flushBarKey = GlobalKey();

Widget build(BuildContext) {
   return FlushBar(key: flushBarKey),
}

void foo(){
  (flushBarKey.currentWidget as FlushBar).dismiss();
}
Related