Skip to main content

EkycLivenessWidget

The pre-built widget that captures camera frames, optionally runs on-device face detection, and POSTs to /v1/liveness/check. Drop it into a screen and wire the callbacks.

import 'package:ekyc_sdk/widgets.dart';

EkycLivenessWidget(
sdk: sdk,
mode: LivenessMode.passive,
onResult: (LivenessCheckResult r) {
Navigator.of(context).pop(r);
},
onError: (EkycError e) {
showDialog(/* ... */);
},
);

mode parameter

ModeFramesBackend behavior
LivenessMode.passive1Anti-spoof + deepfake check on a single frame
LivenessMode.burst3-5Above + temporal consistency check
LivenessMode.challenge2-5Above + verifies the user performed the requested action

For challenge mode, mint a challenge token first:

final ch = await sdk.liveness.challenge(actionHint: LivenessAction.blink);

EkycLivenessWidget(
sdk: sdk,
mode: LivenessMode.challenge,
challengeToken: ch.challengeToken,
action: ChallengeAction.blink,
onResult: (r) { /* ... */ },
);

Result fields

LivenessCheckResult mirrors the gateway response:

  • lcId — stable id, format lc_<32hex>. Persist this for audit.
  • isLive — boolean verdict.
  • score / threshold — numeric score and the threshold it was compared against.
  • reasonnull when isLive is true; otherwise a tag like 'no_face', 'face_too_small', 'spoofed'.
  • mode — confirms which mode the gateway processed.
  • requestId — for support tickets.

Customizing the camera UI

The widget renders a default camera preview with a built-in capture trigger. To customize, swizzle the widget:

cd your-app
flutter run --debug # one-time, generates the override stub

…and override EkycLivenessWidget like any other Flutter widget. The SDK does not provide theming hooks beyond standard Material/ Cupertino styling.