BankPanicFreezeButton class
Hold-to-activate emergency "freeze everything" control.
One panic gesture blocks all cards and outgoing payments.
Two visual states, driven by frozen:
- Unfrozen: a large, danger-outlined circular button with a snowflake
icon. The user must press and hold for holdDuration; a circular
progress ring fills while held and the button scales down slightly for
tactile feedback. Releasing early cancels the gesture and the ring
unwinds. When the hold completes, onToggle runs with
freeze: trueand a spinner replaces the icon until it resolves; on success the widget flips to the frozen state. - Frozen: a filled danger surface showing frozenLabel, frozenBody,
and an unfreeze button. Unfreezing is deliberately harder to do by
accident: it opens a confirmation dialog first, and only then calls
onToggle with
freeze: false.
If onToggle returns false or throws, the widget stays in its current
state and rearms.
Reduced motion: when animations are disabled (see MediaQuery.disableAnimationsOf), the hold is still required for the full holdDuration, but the progress ring advances in discrete steps instead of sweeping continuously, and the press scale effect is skipped.
Accessibility: both states expose full Semantics. The hold button is announced as a button with a hint describing the press-and-hold gesture and its duration; the unfreeze button announces that a confirmation dialog follows.
BankPanicFreezeButton(
frozen: account.securityFreezeActive,
onToggle: (freeze) => securityRepo.setGlobalFreeze(freeze),
)
References: colours, radii, spacing, and motion come from
BankThemeData and BankTokens; the snowflake icon is
BankIcons.cardFreeze.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- BankPanicFreezeButton
Constructors
-
BankPanicFreezeButton({required bool frozen, required Future<
bool> onToggle(bool freeze), Key? key, Duration holdDuration = const Duration(milliseconds: 1500), String freezeLabel = 'Hold to freeze everything', String frozenLabel = 'Everything is frozen', String unfreezeLabel = 'Unfreeze', String frozenBody = 'Cards and outgoing payments are blocked', String unfreezeConfirmTitle = 'Unfreeze everything?', String unfreezeConfirmBody = 'Your cards and outgoing payments will start working again.', String cancelLabel = 'Cancel', Color? accentColor, Color? foregroundColor, IconData? icon, double? size, BorderRadius? radius, EdgeInsetsGeometry? padding, TextStyle? labelStyle, TextStyle? frozenTitleStyle, TextStyle? frozenBodyStyle, String? holdHint, String unfreezeHint = 'Opens a confirmation dialog before unfreezing', Duration? animationDuration, Curve? animationCurve}) -
const
Properties
- accentColor → Color?
-
Overrides the danger accent (ring, borders, icons, frozen surface).
Defaults to BankTokens.danger.
final
- animationCurve → Curve?
-
Overrides the state cross-fade and press-scale curves. Defaults to
BankTokens.curveStandard and BankTokens.curveEmphasized.
final
- animationDuration → Duration?
-
Overrides the state cross-fade and press-scale durations. Defaults
to BankTokens.durationBase and BankTokens.durationFast.
final
- cancelLabel → String
-
Label of the dialog action that keeps everything frozen.
final
- foregroundColor → Color?
-
Overrides the text and icon colour on the frozen panel. Defaults to
white.
final
- freezeLabel → String
-
Label under the circular button in the unfrozen state.
final
- frozen → bool
-
Whether everything is currently frozen. The widget also flips its own
state optimistically after a successful onToggle, so parents may
rebuild lazily.
final
- frozenBody → String
-
Supporting text of the frozen panel.
final
- frozenBodyStyle → TextStyle?
-
Merged over the computed frozenBody style
(BankTokens.bodySmall).
final
- frozenLabel → String
-
Headline of the frozen panel.
final
- frozenTitleStyle → TextStyle?
-
Merged over the computed frozenLabel style
(BankTokens.headlineSmall).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- holdDuration → Duration
-
How long the button must be held before the freeze fires.
final
- holdHint → String?
-
Overrides the semantics hint of the hold button. Defaults to a
press-and-hold instruction including the hold duration.
final
- icon → IconData?
-
Overrides the snowflake glyph in both states. Defaults to
BankIcons.cardFreeze.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- labelStyle → TextStyle?
-
Merged over the computed freezeLabel style
(BankTokens.labelLarge).
final
-
onToggle
→ Future<
bool> Function(bool freeze) -
Executes the freeze (
freeze == true) or unfreeze (freeze == false) operation. Returntrueon success;false(or throw) to keep the current state.final - padding → EdgeInsetsGeometry?
-
Overrides the frozen panel content padding. Defaults to
BankTokens.space5 on all sides.
final
- radius → BorderRadius?
-
Overrides the frozen panel corner radius. Defaults to
BankThemeData.cardRadius.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → double?
-
Overrides the hold button diameter. Defaults to
128.final - unfreezeConfirmBody → String
-
Body of the unfreeze confirmation dialog.
final
- unfreezeConfirmTitle → String
-
Title of the unfreeze confirmation dialog.
final
- unfreezeHint → String
-
Semantics hint of the unfreeze button. Defaults to
'Opens a confirmation dialog before unfreezing'.final - unfreezeLabel → String
-
Label of the unfreeze button and of the confirming dialog action.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< BankPanicFreezeButton> -
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