Flutter Snackbar Helper

A simple singleton helper class for showing snackbars

Features

  • Display error, success, or info snackbars!
  • Snackbar adjusts how long it displays based on the length of the string content
  • Snackbar contents is scrollable
  • Optional maximum duration
  • Optional custom colors

Usage

Simply call SnackbarHelper whenever you want to show a snackbar message:

ElevatedButton(
  onPressed: () {
    if( errorHappened() ) {
      SnackbarHelper.error(context, "An error occurred!");
    }
    else if( successHappened()) {
      SnackbarHelper.success(context, "Success!");
    } else {
      SnackbarHelper.info(context, "Some extra info");
    }
  },
  ...
);