FaceCaptureController class
Owns the camera, runs ML Kit face detection, sequences the capture
steps, and uploads the result. This is a plain ChangeNotifier —
no bloc/riverpod/provider dependency. Any widget can listen to it
with ListenableBuilder or AnimatedBuilder, both built into Flutter.
Usage:
final controller = FaceCaptureController(config: config, repository: repo);
await controller.initialize();
// controller.state has everything the UI needs
controller.addListener(() { ... rebuild ... });
controller.dispose(); // when done
- Inheritance
-
- Object
- ChangeNotifier
- FaceCaptureController
Constructors
- FaceCaptureController({required FaceCaptureConfig config})
Properties
- config → FaceCaptureConfig
-
final
- currentStep → FacePoseStep
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → FaceCaptureState
-
Current snapshot. Read this in your widget's build method.
no setter
- stepsCount → int
-
Total number of steps in this flow (respects a custom
config.steps).no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
captureCurrentStep(
) → Future< void> - Called automatically after the hold duration, or manually if FaceCaptureConfig.autoCapture is false and your UI wires up a button.
-
dispose(
) → void -
IMPORTANT: call this from your widget's
dispose(), same as any other ChangeNotifier-based controller (e.g. a TextEditingController).override -
initialize(
) → Future< void> -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
retry(
) → Future< void> - Reset and start the whole sequence over (e.g. after an error).
-
submit(
{required String userId}) → Future< void> -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
preload(
) → Future< void> - Loads camera names, pose GIFs, and the face-detection model. Call from app startup (after runApp or WidgetsFlutterBinding.ensureInitialized) so the capture screen does not hitch on first open.
-
prepareCamera(
) → Future< CameraController> - Starts the front camera while the capture route is opening. Does not wait for GIF decode or ML Kit warmup.