FaceDetectionLock class

A widget that locks its body behind face detection.

When a face is detected (and optionally verified), the body is shown. Otherwise, a lock screen is displayed.

// Simplest usage — any face unlocks
FaceDetectionLock(body: MyApp());

// With verification — only enrolled faces unlock
FaceDetectionLock(
  verificationProvider: LocalFaceVerificationProvider(),
  body: MyApp(),
);
Inheritance

Constructors

FaceDetectionLock({Key? key, required Widget body, Widget? noCameraDetectedErrorScreen, Widget? noFaceLockScreen, Widget? initializingCameraScreen, Widget? permissionDeniedScreen, Widget? pausedScreen, Widget errorScreen(String message)?, Widget? unverifiedScreen, Widget? tooManyFacesScreen, bool isBlocInitializeAbove = false, CameraController? cameraController, FaceVerificationProvider? verificationProvider, int? maxFaces, MultiFacePolicy multiFacePolicy = MultiFacePolicy.lockIfMultiple, Duration transitionDuration = const Duration(milliseconds: 300), bool enableHapticFeedback = false})
const

Properties

body → Widget
The widget to secure behind the face detection lock.
final
cameraController → CameraController?
Pass an existing CameraController if you manage the camera elsewhere.
final
enableHapticFeedback → bool
Whether to trigger haptic feedback on lock/unlock transitions.
final
errorScreen → Widget Function(String message)?
Custom screen shown when initialization fails.
final
hashCode → int
The hash code for this object.
no setterinherited
initializingCameraScreen → Widget?
Custom loading screen shown while the camera is initializing.
final
isBlocInitializeAbove → bool
Set to true if the BlocProvider is initialized higher in the widget tree.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxFaces → int?
Maximum number of faces allowed before locking. When null (default), any number of faces is accepted. Only used when isBlocInitializeAbove is false.
final
multiFacePolicy → MultiFacePolicy
Policy for handling multiple detected faces. Only used when isBlocInitializeAbove is false.
final
noCameraDetectedErrorScreen → Widget?
Custom error widget shown when no camera is detected on the device.
final
noFaceLockScreen → Widget?
Custom lock screen shown when no face is detected.
final
pausedScreen → Widget?
Custom screen shown when detection is paused (app backgrounded).
final
permissionDeniedScreen → Widget?
Custom screen shown when camera permission is denied.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tooManyFacesScreen → Widget?
Custom screen shown when more faces than maxFaces are detected.
final
transitionDuration → Duration
Duration of the fade transition between lock/unlock states.
final
unverifiedScreen → Widget?
Custom screen shown when a face is detected but not verified.
final
verificationProvider → FaceVerificationProvider?
Optional face verification provider.
final

Methods

build(BuildContext context) → Widget
Describes the part of the user interface represented by this widget.
override
createElement() → StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
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