Skip to main content
Stac snackBar allows you to show the Flutter SnackBar using JSON. To know more about the SnackBar widget in Flutter, refer to the official documentation.

SnackBar Properties

PropertyTypeDescription
contentStacWidgetThe primary content of the snack bar.
backgroundColorStacColorThe snack bar’s background color.
elevationdoubleThe z-coordinate at which to place the snack bar.
marginStacEdgeInsetsEmpty space to surround the snack bar.
paddingStacEdgeInsetsThe amount of padding to apply to the snack bar’s content and optional action.
widthdoubleThe width of the snack bar.
shapeStacShapeBorderThe shape of the snack bar.
hitTestBehaviorStacHitTestBehaviorDefines how the snack bar area, including margin, will behave during hit testing.
behaviorStacSnackBarBehaviorThis defines the behavior and location of the snack bar.
actionStacSnackBarActionAn action that the user can take based on the snack bar.
actionOverflowThresholddoubleThe percentage threshold for action widget’s width before it overflows to a new line.
showCloseIconboolWhether to include a close icon widget.
closeIconColorStacColorAn optional color for the close icon, if close icon visible.
durationStacDurationThe duration for which the snack bar is visible.
onVisibleStacActionCalled the first time that the snackbar is visible.
dismissDirectionStacDismissDirectionThe direction in which the SnackBar can be dismissed.
clipBehaviorStacClipThe content will be clipped (or not) according to this option.

SnackBarAction Properties

PropertyTypeDescription
textColorStringThe button label color.
disabledTextColorStringThe button disabled label color.
backgroundColorStringThe button background fill color.
disabledBackgroundColorStringThe button disabled label color.
labelStringThe button label.
onPressedMap<String, dynamic>The callback to be called when the button is pressed.

Example

StacSnackBarAction(
  content: StacText(data: 'This is a Snackbar'),
  action: StacSnackBarActionButton(
    label: 'Done',
    textColor: StacColors.blue,
    onPressed: StacNoneAction(),
  ),
  behavior: SnackBarBehavior.floating,
)