Flushbar
A flexible widget for user notification. Customize your text, button, duration, animations and much more. For Android devs, it is made to replace Snackbars and Toasts.
Use this package if you need more customization when notifying your user. For Android developers, it is made to substitute toasts and snackbars. IOS developers, I don't know what you use there, but you will like it.
See the install instructions.
This is a flutter widget inspired by Flashbar. Development of Flushbar and Flashbar are totally separate.
Quick reference
Since customization requires a lot of properties, here is a quick cheatsheet:
PROPERTY | WHAT DOES IT DO |
---|---|
title | The title displayed to the user |
message | The message displayed to the user. |
titleText | Replaces [title]. Although this accepts a [widget], it is meant to receive [Text] or [RichText] |
messageText | Replaces [message]. Although this accepts a [widget], it is meant to receive [Text] or [RichText] |
icon | You can use any widget here, but I recommend [Icon] or [Image] as indication of what kind of message you are displaying. Other widgets may break the layout |
shouldIconPulse | An option to animate the icon (if present). Defaults to true. |
aroundPadding | Adds a custom padding to Flushbar |
borderRadius | Adds a radius to all corners of Flushbar. Best combined with [aroundPadding]. I do not recommend using it with [showProgressIndicator] or [leftBarIndicatorColor] |
backgroundColor | Flushbar background color. Will be ignored if [backgroundGradient] is not null. |
leftBarIndicatorColor | If not null, shows a left vertical bar to better indicate the humor of the notification. It is not possible to use it with a [Form] and I do not recommend using it with [LinearProgressIndicator]. |
boxShadows | The shadows generated by Flushbar. Leave it null if you don't want a shadow. You can use more than one if you feel the need. Check this example |
backgroundGradient | Flushbar background gradient. Makes [backgroundColor] be ignored. |
mainButton | A [FlatButton] widget if you need an action from the user. |
onTap | A callback that registers the user's click anywhere. An alternative to [mainButton] |
duration | How long until Flushbar will hide itself (be dismissed). To make it indefinite, leave it null. |
isDismissible | Determines if the user can swipe to dismiss the bar. It is recommended that you set a [duration] if [isDismissible] is false. If the user swipes to dismiss it, no value will be returned. |
dismissDirection | FlushbarDismissDirection.VERTICAL by default. Can also be [FlushbarDismissDirection.HORIZONTAL] in which case both left and right dismiss are allowed. |
flushbarPosition | Flushbar can be based on [FlushbarPosition.TOP] or on [FlushbarPosition.BOTTOM] of your screen. [FlushbarPosition.BOTTOM] is the default. |
flushbarStyle | Flushbar can be floating or be grounded to the edge of the screen. If grounded, I do not recommend using [aroundPadding] or [borderRadius]. [FlushbarStyle.FLOATING] is the default |
forwardAnimationCurve | The [Curve] animation used when show() is called. [Curves.easeOut] is default. |
reverseAnimationCurve | The [Curve] animation used when dismiss() is called. [Curves.fastOutSlowIn] is default. |
animationDuration | Use it to speed up or slow down the animation duration |
showProgressIndicator | true if you want to show a [LinearProgressIndicator]. |
progressIndicatorController | An optional [AnimationController] when you want to control the progress of your [LinearProgressIndicator]. |
progressIndicatorBackgroundColor | a [LinearProgressIndicator] configuration parameter. |
progressIndicatorValueColor | a [LinearProgressIndicator] configuration parameter. |
overlayBlur | Default is 0.0. If different than 0.0, creates a blurred overlay that prevents the user from interacting with the screen. The greater the value, the greater the blur. |
overlayColor | Default is [Colors.transparent]. Only takes effect if [overlayBlur] > 0.0. Make sure you use a color with transparency e.g. Colors.grey[600].withOpacity(0.2) . |
userInputForm | A [TextFormField] in case you want a simple user input. Every other widget is ignored if this is not null. |
onStatusChanged | a callback for you to listen to the different Flushbar status |
We are on YouTube!
While studying Flutter I stumbled on two amazing tutorials on how to use Flushbar.
Make sure you show those guys some love.
Make sure you show those guys some love.
- A beginners tutorial by Matej Rešetár
- A more advanced usage by Javier González RodrÃguez
Getting Started
The examples bellow were updated for version 1.3.0. Changes might have been made. See the changelog if any of the examples do not
reflect Flushbar's current state.
reflect Flushbar's current state.
The possibilities
A basic Flushbar
The most basic Flushbar uses only a message. Failing to provide it before you call
show()
will result in a runtime error.Duration
, if not provided, will create an infinite Flushbar, only dismissible by code, back button clicks, or a drag (case isDismissible
is set to true
).- Note that only
message
is a required parameter. All the other ones are optional