ZetaSnackBar constructor
- Key? key,
- SnackBarBehavior? behavior = SnackBarBehavior.floating,
- EdgeInsetsGeometry? margin,
- required BuildContext context,
- required Widget content,
- VoidCallback? onPressed,
- ZetaSnackBarType? type,
- Widget? leadingIcon,
- bool? rounded,
- String? actionLabel,
- @Deprecated('Use actionLabel instead.' ' Deprecated in 0.12.1') String? deleteActionLabel,
- @Deprecated('Use actionLabel instead.' ' Deprecated in 0.12.1') String? viewActionLabel,
- String? actionSemanticLabel,
Sets basic styles for the SnackBar.
Implementation
ZetaSnackBar({
super.key,
super.behavior = SnackBarBehavior.floating,
super.margin,
/// Context required to get the theme and colors.
required BuildContext context,
/// The main content of the snackbar.
required Widget content,
/// Callback to be called when the action button is pressed.
VoidCallback? onPressed,
/// Type used to define contextual [SnackBar]. The type defines the styles, icons and behavior.
ZetaSnackBarType? type,
/// Icon to display at the start of the content.
///
/// Should be of type [ZetaIcon] or [Icon].
Widget? leadingIcon,
/// {@macro zeta-widget-rounded}
bool? rounded,
/// Label for the action button.
///
/// Depending on the `type`, the default label will be used; 'Undo' for [ZetaSnackBarType.deletion] and 'View' for [ZetaSnackBarType.view].
String? actionLabel,
/// Label for the delete action button.
///
/// If null, 'Delete' will be used.
@Deprecated('Use actionLabel instead.' ' Deprecated in 0.12.1') String? deleteActionLabel,
/// Label for the view action button.
///
/// If null, 'View' will be used.
@Deprecated('Use actionLabel instead.' ' Deprecated in 0.12.1') String? viewActionLabel,
/// Semantic label for the action button.
///
/// If null, the `actionLabel` will be used.
String? actionSemanticLabel,
}) : super(
elevation: 0,
padding: EdgeInsets.zero,
backgroundColor: _getBackgroundColorForType(context, type),
shape: RoundedRectangleBorder(
borderRadius: type != null
? Zeta.of(context).radius.full
: rounded ?? context.rounded
? Zeta.of(context).radius.minimal
: Zeta.of(context).radius.none,
),
content: ZetaRoundedScope(
rounded: rounded ?? context.rounded,
child: Padding(
padding: EdgeInsets.symmetric(vertical: Zeta.of(context).spacing.small),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
child: Row(
children: [
_LeadingIcon(type, leadingIcon),
Flexible(
child: Padding(
padding: EdgeInsets.only(left: Zeta.of(context).spacing.medium),
child: _Content(type: type, child: content),
),
),
],
),
),
_Action(
type: type,
actionLabel: actionLabel,
onPressed: onPressed,
deleteActionLabel: deleteActionLabel,
viewActionLabel: viewActionLabel,
semanticLabel: actionSemanticLabel,
),
],
),
),
),
);