BiometricBuilder class

Reactive widget that rebuilds when biometric auth state changes.

Like FutureBuilder but for biometric authentication. Handles lifecycle events (app resume), session stream subscription, and state management.

Example:

BiometricBuilder(
  shield: shield,
  reason: 'Confirm to view health records',
  userId: user.id,
  reauthOnResume: true,
  builder: (context, state) => switch (state) {
    AuthIdle() => MyIdleScreen(),
    AuthAuthenticating() => MyLoadingScreen(),
    AuthAuthenticated(:final session, :final token) => HealthRecordsScreen(),
    AuthFailed(:final result) => MyErrorScreen(result: result),
  },
)
Inheritance

Constructors

BiometricBuilder({Key? key, required BiometricShieldInterface shield, required String reason, String? userId, bool reauthOnResume = false, bool autoAuthenticate = true, required Widget builder(BuildContext context, AuthState state)})
const

Properties

autoAuthenticate bool
If true, automatically triggers authentication on widget mount. If false, waits for the caller to explicitly trigger auth via _BiometricBuilderState.authenticate.
final
builder Widget Function(BuildContext context, AuthState state)
Builder function that receives the current auth state.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
reason String
Reason shown in the biometric prompt.
final
reauthOnResume bool
If true, re-triggers authentication when app resumes from background and the session has expired.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shield BiometricShieldInterface
The BiometricShield instance to use for authentication. Accepts the interface for DI/testing.
final
userId String?
Override userId for this builder instance. Defaults to BiometricConfig.defaultUserId.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<BiometricBuilder>
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