BankToastBanner class
A toast-style banner that slides in from the top of its parent.
The host app controls visibility via isVisible. When isVisible becomes
true the banner animates in and, after autoHideDuration, calls
onDismiss so the host can set isVisible back to false.
Colours:
- BankToastVariant.success
#34C759(white text) - BankToastVariant.error
#FF3B30(white text) - BankToastVariant.info
BankThemeData.primary(white text) - BankToastVariant.warning
#FF9500(white text)
Accessibility: the widget is marked as a liveRegion so screen readers
announce the message as soon as it appears.
BankToastBanner(
variant: BankToastVariant.success,
message: 'Payment sent successfully.',
isVisible: _showToast,
onDismiss: () => setState(() => _showToast = false),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- BankToastBanner
Constructors
- BankToastBanner({required BankToastVariant variant, required String message, required bool isVisible, Key? key, String? actionLabel, VoidCallback? onAction, VoidCallback? onDismiss, Duration autoHideDuration = const Duration(seconds: 4), bool hapticFeedback = true, EdgeInsetsGeometry? padding, BorderRadius? radius, Color? backgroundColor, Color? foregroundColor, double? elevation, IconData? icon, TextStyle? messageStyle, String dismissLabel = 'Dismiss', String? semanticLabel, Duration? animationDuration, Curve? animationCurve})
-
const
Properties
- actionLabel → String?
-
Optional label for an action button inside the banner.
final
- animationCurve → Curve?
-
Overrides the slide-in curve. Defaults to
BankTokens.curveDecelerate.
final
- animationDuration → Duration?
-
Overrides the slide-in duration. Defaults to
BankTokens.durationBase.
final
- autoHideDuration → Duration
-
How long to wait before auto-dismissing the banner.
final
- backgroundColor → Color?
-
Overrides the per-variant background colour.
final
- dismissLabel → String
-
Semantics label and tooltip of the close button. Defaults to
'Dismiss'.
final
- elevation → double?
-
Overrides the banner elevation. Defaults to
4; pass0to flatten the banner.final - foregroundColor → Color?
-
Overrides the icon, text, and button colour. Defaults to white.
final
- hapticFeedback → bool
-
When
true, calls HapticFeedback.lightImpact when the banner appears.final - hashCode → int
-
The hash code for this object.
no setterinherited
- icon → IconData?
-
Overrides the per-variant leading glyph.
final
- isVisible → bool
-
Whether the banner is currently visible.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- message → String
-
The message text displayed in the banner.
final
- messageStyle → TextStyle?
-
Merged over the computed message style (BankTokens.bodyMedium
in the foreground colour).
final
- onAction → VoidCallback?
-
Callback invoked when the action button is tapped.
final
- onDismiss → VoidCallback?
-
Callback invoked when the banner should be dismissed.
final
- padding → EdgeInsetsGeometry?
-
Overrides the content padding. Defaults to BankTokens.space4
horizontal by BankTokens.space3 vertical.
final
- radius → BorderRadius?
-
Overrides the banner corner radius. Defaults to
BankTokens.radiusMedium.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- semanticLabel → String?
-
Overrides the live-region label. Defaults to
'
<variant name>:<message>'.final - variant → BankToastVariant
-
Visual variant that determines the background colour and leading icon.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< BankToastBanner> -
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
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, int wrapWidth = 65}) → 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