Snackbar Variants

Loading preview

Starting the Flutter app

Simple, action, icon, error, and persistent snackbar styles

Get the source

Add it to your project

Copies the Dart source into your app, so you own it. Flutter SDK only, no extra packages.

First time? Run dart pub global activate fluttertemplates_dev, or read the CLI guide.

How it works

Four FilledButtons each call ScaffoldMessenger.of(context).showSnackBar with a different configuration: plain, with a SnackBarAction, with a green icon row, and error-colored. Repeated taps queue up rather than replacing the current bar, since nothing hides it first. The Undo callback only confirms with another SnackBar, and the success color is hardcoded while the error one comes from the theme.

Adapting it

  • Call hideCurrentSnackBar before showSnackBar if newer messages should win.
  • Put your restore logic in onPressed on SnackBarAction.
  • Wrap these in one helper taking the message and type, and replace Colors.green with a theme extension color.