BankBiometricPromptButton class
A tappable button that triggers an injected biometric authentication callback and reflects its outcome visually.
This widget never calls any platform API directly. The host app provides
onAuthenticate, which wraps the platform-specific authentication logic
(e.g. local_auth). A return value of true signals success; false
signals a user-facing failure.
State machine:
- idle: shows type-appropriate icon above label.
- loading: replaces icon with a CircularProgressIndicator.
- success: briefly shows a green checkmark (750 ms) then calls onSuccess and returns to idle.
- error: calls onError with
'Authentication failed'and returns to idle after 500 ms.
BankBiometricPromptButton(
onAuthenticate: () => LocalAuth.instance.authenticate(
localizedReason: 'Confirm your identity',
),
onSuccess: () => Navigator.of(context).pushReplacement(dashboardRoute),
label: 'Log in with Face ID',
type: BankBiometricType.face,
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- BankBiometricPromptButton
Constructors
-
BankBiometricPromptButton({required Future<
bool> onAuthenticate(), Key? key, VoidCallback? onSuccess, ValueChanged<String> ? onError, String label = 'Use Biometrics', BankBiometricType type = BankBiometricType.fingerprint, IconData? icon, IconData? successIcon, IconData? errorIcon, double? iconSize, Color? accentColor, Color? successColor, Color? errorColor, TextStyle? labelStyle, String? semanticLabel, String errorMessage = 'Authentication failed', Duration? animationDuration, Curve? animationCurve}) -
const
Properties
- accentColor → Color?
-
Overrides the idle icon and spinner colour. Defaults to
BankThemeData.primary.
final
- animationCurve → Curve?
-
Overrides the press-scale and icon-switch curve. Defaults to
BankTokens.curveStandard.
final
- animationDuration → Duration?
-
Overrides the press-scale and icon-switch duration. Defaults to
BankTokens.durationFast.
final
- errorColor → Color?
-
Overrides the error icon colour. Defaults to
BankThemeData.negativeBalance.
final
- errorIcon → IconData?
-
Overrides the error glyph. Defaults to BankIcons.error.
final
- errorMessage → String
-
Message passed to onError on failure. Defaults to
'Authentication failed'.final - hashCode → int
-
The hash code for this object.
no setterinherited
- icon → IconData?
-
Overrides the idle glyph. Defaults to the type-appropriate
BankIcons glyph.
final
- iconSize → double?
-
Overrides the glyph size. Defaults to
48.final - key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- label → String
-
Button label displayed below the icon. Defaults to
'Use Biometrics'.final - labelStyle → TextStyle?
-
Merged over the computed label style (BankTokens.labelLarge in
BankThemeData.onSurface).
final
-
onAuthenticate
→ Future<
bool> Function() -
Called when the button is tapped. Must return
trueon success andfalse(or throw) on failure. Throwing is treated identically to returningfalse.final -
onError
→ ValueChanged<
String> ? -
Called with an error message when onAuthenticate returns
false.final - onSuccess → VoidCallback?
-
Called after a successful authentication and a brief checkmark display.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- semanticLabel → String?
-
Overrides the semantics label. Defaults to label.
final
- successColor → Color?
-
Overrides the success icon colour. Defaults to
BankThemeData.positiveBalance.
final
- successIcon → IconData?
-
Overrides the success glyph. Defaults to BankIcons.success.
final
- type → BankBiometricType
-
Determines the icon displayed. Defaults to
BankBiometricType.fingerprint.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< BankBiometricPromptButton> -
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