Face Recognition with Liveness Detection for Web Support

This commit is contained in:
2026-03-08 10:19:03 +08:00
parent d3da8901a4
commit a8751ca728
7 changed files with 513 additions and 196 deletions
@@ -21,6 +21,9 @@ Future<FaceLivenessResult?> runFaceLiveness(
}) async {
String? capturedPath;
final colors = Theme.of(context).colorScheme;
final textTheme = Theme.of(context).textTheme;
await Navigator.of(context).push(
MaterialPageRoute(
builder: (ctx) => LivenessCheckScreen(
@@ -35,10 +38,33 @@ Future<FaceLivenessResult?> runFaceLiveness(
// Don't pop in onCancel/onError — the package's AppBar
// already calls Navigator.pop() after invoking these.
),
// Remove the default placeholder from inside the camera circle;
// it is shown below via customBottomWidget instead.
placeholder: null,
theme: LivenessCheckTheme(
backgroundColor: colors.surface,
overlayColor: colors.surface.withAlpha(230),
primaryColor: colors.primary,
borderColor: colors.primary,
textColor: colors.onSurface,
errorColor: colors.error,
successColor: colors.tertiary,
),
settings: LivenessCheckSettings(
requiredBlinkCount: requiredBlinks,
requireSmile: false,
autoNavigateOnSuccess: false,
// Must be false so that customBottomWidget is shown.
showTryAgainButton: false,
),
// Challenge instruction rendered below the camera circle.
customBottomWidget: Padding(
padding: const EdgeInsets.fromLTRB(24, 4, 24, 24),
child: Text(
'Blink $requiredBlinks times or smile naturally to continue',
textAlign: TextAlign.center,
style: textTheme.bodyLarge?.copyWith(color: colors.onSurface),
),
),
),
),