Skip to main content

SnackBar

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
contentMap<String, dynamic>The primary content of the snack bar.
backgroundColorStringThe snack bar's background color.
elevationdoubleThe z-coordinate at which to place the snack bar. This controls the size of the shadow below 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.
hitTestBehaviorHitTestBehaviorDefines how the snack bar area, including margin, will behave during hit testing.
behaviorSnackBarBehaviorThis 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.
closeIconColorStringAn optional color for the close icon, if close icon visible.
durationStacDurationThe duration for which the snack bar is visible.
onVisibleMap<String, dynamic>Called the first time that the snackbar is visible.
dismissDirectionDismissDirectionThe direction in which the SnackBar can be dismissed.
clipBehaviorClipThe 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 JSON​

{
"actionType": "showSnackBar",
"content": {
"type": "text",
"data": "This is a Snackbar"
},
"action": {
"label": "Done",
"textColor": "#73C2FB",
"onPressed": {}
},
"behavior": "floating"
}