flushbar
flushbar copied to clipboard
[Question] Possibility to create a class
Hello everyone,
Is possible to create a class to be able to use the Flushbar
with a default value. I mean, every time that you need to present an error you can invoke that class that has the default value, as well as a class for info.
How can I approach it?
I guess the lib by default doesn't support it. Some alternatives would be:
- Extends Flushbar
class FlushbarError extends Flushbar {}
- Make another class just like FlushbarHelper, but with your data
class MyFlushbarHelper {
static void static void showError(...) {
return Flushbar(...);
}
}
But the ideal would be the possibility create the snackbars with default values, and be allowed to change them on demand.
I have a LittleHelper
class that I use to display errors, alerts, dialogs, and other such repetitive things. I've implemented it with a factory, so that it gets the BuildContext
automatically, like so:
class LittleHelper {
final BuildContext context;
LittleHelper(this.context);
factory LittleHelper.of(BuildContext context) {
return LittleHelper(context);
}
...
}
Which then allows me to just do this:
LittleHelper.of(context).showAlert(...); // Displays a Flushbar.