EZ Flutter supports displaying a message to the user from anywhere inside the app with just one line of code.
Global Messaging is handled with a BLOC and widget added as the body of a Scaffold.
To activate the Global Messaging feature, you can use the build in scaffolds.
If you don't want to use the build in scaffold widgets, check out the next step! Otherwise skip it.
Add the EzGlobalMessageWrapper as the body to a Scaffold.
Scaffold {
appBar: ...
body: EzGlobalMessageWrapper(
MyWidget(
...
)
)
}
Load the EzMessageBloc via the EzBlocProvider using the get() method.
Add a EzMessage to the bloc. The supported EzMessageTypes are :
EzBlocProvider.of<EzGlobalBloc>(context)
.get(EzMessageBloc)
.addition
.add(EzMessage("This is a success message", EzMessageType.SUCCESS));
It is also possible to customize the color for each type of message within the ez_settings.json file.
{
"msg_success_color" : "0xFF1B5E20",
"msg_info_color" : "0xFF0D47A1",
"msg_warning_color" : "0xFFE65100",
"msg_error_color" : "0xFFB71C1C",
"msg_error_debug" : "0xFFB71C1C",
}