FaceGateCloudProvider class

A FaceVerificationProvider that delegates verification and template storage to a remote REST API (e.g. face_gate_cloud).

Face features are extracted on-device using FaceFeatureExtractor and sent as numeric vectors to the backend. The backend performs matching and stores templates.

final provider = FaceGateCloudProvider(
  baseUrl: 'https://api.facegate.example.com',
  apiKey: 'your-api-key',
);

// Use standalone
final result = await provider.verify(detectedFace);

// Or inject into the lock widget via the controller
FaceDetectionController(verificationProvider: provider);

Implementing a custom backend

Any HTTP server that conforms to the following contract will work:

Method Path Body Response
POST /api/v1/verify {"features": [...]} {"isMatch": bool, "confidence": double, "matchedTemplateId": string?}
POST /api/v1/enroll {"label": string, "features": [...]} {"id": string, "label": string, "features": [...], "createdAt": string}
GET /api/v1/templates [{"id": ..., "label": ..., ...}, ...]
DELETE /api/v1/templates/{id} 204
DELETE /api/v1/templates 204
GET /api/v1/health {"status": "ok"}
Implemented types

Constructors

FaceGateCloudProvider({required String baseUrl, String? apiKey, Duration timeout = const Duration(seconds: 10), int retryCount = 1, String basePath = '/api/v1', Client? httpClient, LivenessChecker? livenessChecker})

Properties

apiKey String?
Optional API key sent in the Authorization header as Bearer.
final
basePath String
Base path prefix for all API endpoints. Defaults to /api/v1.
final
baseUrl String
Base URL of the face verification API (e.g. https://api.facegate.io).
final
hashCode int
The hash code for this object.
no setterinherited
retryCount int
Number of retry attempts on transient failures (5xx, timeout). Defaults to 1 (one retry after initial failure).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timeout Duration
HTTP request timeout. Defaults to 10 seconds.
final

Methods

checkLiveness(Face face) Future<LivenessResult>
Check a face for liveness (anti-spoofing).
override
clearAll() Future<void>
Delete all enrolled templates.
override
close() → void
Close the underlying HTTP client.
deleteTemplate(String id) Future<void>
Delete an enrolled template by ID.
override
enroll(String label, List<Face> samples) Future<FaceTemplate>
Enroll a new face from multiple sample captures.
override
health() Future<bool>
Check if the remote API is reachable and healthy.
listTemplates() Future<List<FaceTemplate>>
List all enrolled templates.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
verify(Face face) Future<FaceVerificationResult>
Verify a detected face against enrolled templates.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited