face_detection_lock 0.3.0
face_detection_lock: ^0.3.0 copied to clipboard
Face detection lock screen widget for Flutter. Unlocks when a face is detected.
Changelog #
All notable changes to this project will be documented in this file.
0.3.0 #
Changed #
- Removed
flutter_blocdependency — replacedFaceDetectionBlocwithFaceDetectionController(extendsChangeNotifier). No external state management dependency required. - Removed
bloc_testdev dependency — tests now use standardtest()with stream collection instead ofblocTest<>. - Removed event pattern — replaced
add(Event)dispatch with direct methods:initializeCamera(),pause(),resume(),close(). - Renamed
FaceDetectionBlocProvider→FaceDetectionProvider— a lightweightInheritedWidgetfor dependency injection. - Renamed
isBlocInitializeAbove→isControllerProvidedAbove. - Widget internals —
BlocConsumerreplaced withListenableBuilder. - State file is now a standalone import (no longer a
partfile).
Migration (from 0.2.x) #
- Replace
FaceDetectionBlocwithFaceDetectionController. - Replace
FaceDetectionBlocProvider(bloc: ...)withFaceDetectionProvider(controller: ...). - Replace
bloc.add(const InitializeCam())withcontroller.initializeCamera(). - Replace
bloc.add(const PauseDetection())withcontroller.pause(). - Replace
bloc.add(const ResumeDetection())withcontroller.resume(). - Replace
isBlocInitializeAbovewithisControllerProvidedAbove. - Remove
flutter_blocfrom your app'spubspec.yaml.
0.2.0 #
Added #
- Face verification — optional
verificationProviderparameter enables "only enrolled faces unlock" mode. FaceVerificationProvider— abstract interface for pluggable verification backends (local, cloud, or custom).LocalFaceVerificationProvider— on-device verification using ML Kit contour-based feature extraction and cosine similarity matching.FaceGateCloudProvider— REST client implementingFaceVerificationProviderwith configurablebaseUrl,apiKey,timeout,retryCount, andbasePath.FallbackVerificationProvider— wraps a primary and fallback provider for resilient verification (e.g. cloud-first with local fallback).FaceFeatureExtractor— normalized contour feature extraction with cosine similarity and feature averaging utilities.LivenessChecker— basic anti-spoofing via eye open probability and head euler angle checks.FaceTemplate/FaceVerificationResult/LivenessResultdomain models with JSON serialization.FaceTemplateStore— abstract template storage withInMemoryTemplateStoreimplementation.FaceDetectionUnverifiedstate — emitted when a face is detected but does not match any enrolled template.- Frame throttling — configurable
detectionInterval(default 300ms) skips redundant frames for battery efficiency. - Debounced lock/unlock —
lockDelayandunlockDelayprevent UI flicker from momentary detection gaps. - Smooth transitions —
AnimatedSwitcherwith configurabletransitionDurationbetween lock/unlock states. - Haptic feedback — optional
enableHapticFeedbackon state transitions. - Lifecycle awareness — automatically pauses detection when the app is backgrounded and resumes on foreground.
- Pause / Resume methods and
FaceDetectionPausedstate with previous-state restoration. - Configurable
camDirection,resolution, andminFaceSizeparameters. - Unit tests (15 test cases) and widget tests (17 test cases).
- GitHub Actions CI pipeline (
flutter analyze+flutter test). - Example app with three demo modes: Basic, Verification, and Advanced.
- Comprehensive dartdoc comments on all public APIs.
MIGRATION.md— migration guide from v0.0.1.
Fixed #
- Memory leak — internal
CameraControlleris now properly disposed. - Image stream never stopped on dispose.
- Swapped
noFace/noCameraOnDevicewidget mapping. - Removed dead
Completercode.
Changed #
- Migrated from deprecated
google_ml_visiontogoogle_mlkit_face_detection. - Upgraded to Dart 3 / Flutter 3.x SDK constraints.
- Added
FaceDetectionPermissionDeniedandFaceDetectionInitializationFailederror states. - Added try-catch around camera init and face detection.
- Added configurable camera initialization timeout (
initTimeout). - Added explicit camera permission handling.
Dependencies #
google_mlkit_face_detection: ^0.12.0(replacesgoogle_ml_vision)http: ^1.2.0
0.0.1 #
- Initial release.
- Widget locks screen when no face is detected.
- Face snapshot accessible via callback.