FloatingSnackBarTheme class
Global, app-wide defaults for floating snackbars.
Set this once (typically before runApp) to control how every snackbar
looks and behaves without passing the same arguments at each call site:
FloatingSnackBar.theme = const FloatingSnackBarTheme(
defaultPosition: FloatingSnackBarPosition.top,
borderRadius: 16,
successColor: Colors.teal,
);
Any argument passed directly to FloatingSnackBar.show (or the variant helpers) overrides the matching value from the active theme.
- Annotations
Constructors
- FloatingSnackBarTheme({Color? backgroundColor, Color textColor = Colors.white, TextStyle? textStyle, TextStyle? titleStyle, double borderRadius = 10, EdgeInsets margin = const EdgeInsets.all(20), EdgeInsets padding = const EdgeInsets.symmetric(horizontal: 16, vertical: 14), Duration duration = const Duration(milliseconds: 4000), FloatingSnackBarPosition defaultPosition = FloatingSnackBarPosition.bottom, FloatingSnackBarAnimation animation = FloatingSnackBarAnimation.slide, Duration animationDuration = const Duration(milliseconds: 350), double elevation = 6, bool dismissOnTap = false, bool showProgress = false, Color successColor = const Color(0xFF2E7D32), Color errorColor = const Color(0xFFC62828), Color warningColor = const Color(0xFFF9A825), Color infoColor = const Color(0xFF1565C0), IconData successIcon = Icons.check_circle_rounded, IconData errorIcon = Icons.error_rounded, IconData warningIcon = Icons.warning_rounded, IconData infoIcon = Icons.info_rounded})
-
Creates a theme describing default snackbar styling and behavior.
const
Properties
- animation → FloatingSnackBarAnimation
-
Default entrance/exit animation.
final
- animationDuration → Duration
-
Duration of the entrance/exit animation.
final
- backgroundColor → Color?
-
Background color for FloatingSnackBarType.normal.
final
- borderRadius → double
-
Corner radius of the snackbar card.
final
- defaultPosition → FloatingSnackBarPosition
-
Default screen anchor.
final
- dismissOnTap → bool
-
Whether tapping the snackbar dismisses it.
final
- duration → Duration
-
How long the snackbar stays visible before auto-dismissing.
final
- elevation → double
-
Material elevation (shadow) of the card.
final
- errorColor → Color
-
Background color used for FloatingSnackBarType.error.
final
- errorIcon → IconData
-
Default leading icon for FloatingSnackBarType.error.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- infoColor → Color
-
Background color used for FloatingSnackBarType.info.
final
- infoIcon → IconData
-
Default leading icon for FloatingSnackBarType.info.
final
- margin → EdgeInsets
-
Outer margin between the snackbar and the screen edges.
final
- padding → EdgeInsets
-
Inner padding around the snackbar content.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showProgress → bool
-
Whether a countdown progress bar is shown along the bottom edge.
final
- successColor → Color
-
Background color used for FloatingSnackBarType.success.
final
- successIcon → IconData
-
Default leading icon for FloatingSnackBarType.success.
final
- textColor → Color
-
Default color for the message (and title) text.
final
- textStyle → TextStyle?
-
Default text style for the message. Merged over the resolved textColor.
final
- titleStyle → TextStyle?
-
Default text style for the optional title (defaults to a bold variant of
textStyle when null).
final
- warningColor → Color
-
Background color used for FloatingSnackBarType.warning.
final
- warningIcon → IconData
-
Default leading icon for FloatingSnackBarType.warning.
final
Methods
-
backgroundColorFor(
FloatingSnackBarType type) → Color -
The resolved background color for the given
type. -
copyWith(
{Color? backgroundColor, Color? textColor, TextStyle? textStyle, TextStyle? titleStyle, double? borderRadius, EdgeInsets? margin, EdgeInsets? padding, Duration? duration, FloatingSnackBarPosition? defaultPosition, FloatingSnackBarAnimation? animation, Duration? animationDuration, double? elevation, bool? dismissOnTap, bool? showProgress, Color? successColor, Color? errorColor, Color? warningColor, Color? infoColor, IconData? successIcon, IconData? errorIcon, IconData? warningIcon, IconData? infoIcon}) → FloatingSnackBarTheme - Returns a copy of this theme with the given fields replaced.
-
iconFor(
FloatingSnackBarType type) → IconData? -
The resolved default leading icon for the given
type, or null for FloatingSnackBarType.normal. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited