FlutterToast
FlutterToast copied to clipboard
Does FToast require initialization in every widget?
The docs say that we need to initialize FToast
like this:
@override
void initState() {
super.initState();
fToast = FToast();
fToast.init(context);
}
Does this need to happen in every widget where we intend to show a toast or can I just initialize this once in the top most widget (most likely a MaterialApp.router
widget)?
If the latter is a viable approach, after initializing in the top most widget, which is the safest way of accessing the FToast
instance:
- Show a toast using
FToast().showToast(...)
assuming that it has been initialized once in a parent widget. - Access the
FToast
instance using a provider or some other type of state management solution.