Snackbar<T> class

A highly customizable widget so you can notify your user when you fell like he needs a beautiful explanation.

Inheritance

Constructors

Snackbar({Key? key, String? title, bool? hasLearnMore, Color? textColor, String? learnMoreText, String? message, Widget? titleText, Widget? messageText, bool? isCancelButton, Widget? icon, bool? shouldIconPulse = true, double? maxWidth, double? fontSize, EdgeInsets? margin = const EdgeInsets.all(0.0), EdgeInsets? padding = const EdgeInsets.all(16), double borderRadius = 0.0, Color? borderColor, double? borderWidth = 1.0, Color? backgroundColor = const Color(0xFF303030), Color? leftBarIndicatorColor, List<BoxShadow>? boxShadows, Gradient? backgroundGradient, OnTap? onTap, Duration? duration, bool? isDismissible = true, SnackbarDismissDirection dismissDirection = SnackbarDismissDirection.VERTICAL, bool? showProgressIndicator = false, AnimationController? progressIndicatorController, Color? progressIndicatorBackgroundColor, Animation<Color>? progressIndicatorValueColor, SnackbarPosition? snackbarPosition = SnackbarPosition.BOTTOM, SnackbarStyle? snackbarStyle = SnackbarStyle.FLOATING, Curve forwardAnimationCurve = Curves.easeOutCirc, Curve reverseAnimationCurve = Curves.easeOutCirc, Duration animationDuration = const Duration(seconds: 1), SnackbarStatusCallback? onStatusChanged, VoidCallback? learnMoreCallback, double? barBlur = 0.0, SnackbarRoute? snackbarRoute, bool? blockBackgroundInteraction = false, double? routeBlur, Color? routeColor, Widget? cancelButton, Form? userInputForm})

Properties

animationDuration Duration?
Use it to speed up or slow down the animation duration
final
backgroundColor Color?
Will be ignored if backgroundGradient is not null
final
backgroundGradient Gradient?
Makes backgroundColor be ignored.
final
barBlur double?
Default is 0.0. If different than 0.0, blurs only Snackbar's background. To take effect, make sure your backgroundColor has some opacity. The greater the value, the greater the blur.
final
blockBackgroundInteraction bool?
Determines if user can interact with the screen behind it If this is false, routeBlur and routeColor will be ignored
final
borderColor Color?
Adds a border to every side of Snackbar I do not recommend using it with showProgressIndicator or leftBarIndicatorColor.
final
borderRadius double?
Adds a radius to all corners of Snackbar. Best combined with margin. I do not recommend using it with showProgressIndicator or leftBarIndicatorColor.
final
borderWidth double?
Changes the width of the border if borderColor is specified
final
boxShadows List<BoxShadow>?
boxShadows The shadows generated by Snackbar. Leave it null if you don't want a shadow. You can use more than one if you feel the need. Check (this example)https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/material/shadows.dart
final
cancelButton Widget?
final
dismissDirection SnackbarDismissDirection?
SnackbarDismissDirection.VERTICAL by default. Can also be SnackbarDismissDirection.HORIZONTAL in which case both left and right dismiss are allowed.
final
duration Duration?
How long until Snackbar will hide itself (be dismissed). To make it indefinite, leave it null.
final
fontSize double?
final
forwardAnimationCurve Curve?
The Curve animation used when show() is called. Curves.easeOut is default
final
hashCode int
The hash code for this object.
no setterinherited
hasLearnMore bool?
final
icon Widget?
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
final
isCancelButton bool?
final
isDismissible bool?
Determines if the user can swipe or click the overlay (if routeBlur > 0) to dismiss. It is recommended that you set duration != null if this is false. If the user swipes to dismiss or clicks the overlay, no value will be returned.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
learnMoreCallback VoidCallback?
final
learnMoreText String?
final
leftBarIndicatorColor Color?
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
final
margin EdgeInsets?
Adds a custom margin to Snackbar
final
maxWidth double?
Used to limit Snackbar width (usually on large screens)
final
message String?
The message displayed to the user.
final
messageText Widget?
Replaces message. Although this accepts a Widget, it is meant to receive Text or RichText
final
onStatusChanged SnackbarStatusCallback?
A callback for you to listen to the different Snackbar status
getter/setter pair
onTap OnTap?
Use if you need an action from the user. FlatButton is recommended here A callback that registers the user's click anywhere. An alternative to mainButton
final
padding EdgeInsets?
Adds a custom padding to Snackbar The default follows material design guide line
final
progressIndicatorBackgroundColor Color?
A LinearProgressIndicator configuration parameter.
final
progressIndicatorController AnimationController?
An optional AnimationController when you want to control the progress of your LinearProgressIndicator. You are responsible for controlling the progress
final
progressIndicatorValueColor Animation<Color>?
A LinearProgressIndicator configuration parameter.
final
reverseAnimationCurve Curve?
The Curve animation used when dismiss() is called. Curves.fastOutSlowIn is default
final
routeBlur double?
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. It does not take effect if blockBackgroundInteraction is false
final
routeColor Color?
Default is Colors.transparent. Only takes effect if routeBlur > 0.0. Make sure you use a color with transparency here e.g. Colors.grey600.withOpacity(0.2). It does not take effect if blockBackgroundInteraction is false
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shouldIconPulse bool?
An option to animate the icon (if present). Defaults to true.
final
showProgressIndicator bool?
True if you want to show a LinearProgressIndicator. If progressIndicatorController is null, an infinite progress indicator will be shown
final
snackbarPosition SnackbarPosition?
Snackbar can be based on SnackbarPosition.TOP or on SnackbarPosition.BOTTOM of your screen. SnackbarPosition.BOTTOM is the default.
final
snackbarStyle SnackbarStyle?
Snackbar can be floating or be grounded to the edge of the screen. If grounded, I do not recommend using a backgroundColor with transparency or barBlur
final
textColor Color?
final
title String?
The title displayed to the user
final
titleText Widget?
Replaces title. Although this accepts a Widget, it is meant to receive Text or RichText
final
userInputForm Form?
A TextFormField in case you want a simple user input. Every other widget is ignored if this is not null.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<StatefulWidget>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
isDismissed() bool
Checks if the Snackbar is dismissed
isShowing() bool
Dismisses the Snackbar causing is to return a future containing result. When this future finishes, it is guaranteed that Snackbar was dismissed. Checks if the Snackbar is visible
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
show(BuildContext context) Future<T>
Show the Snackbar. Kicks in SnackbarStatus.IS_APPEARING state followed by SnackbarStatus.SHOWING
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited