Flutter SDK
A guided native flow for Android and iOS that collects the requested documents, runs the liveness challenge and location step, and sends the evidence for review.
credflare_sdk. Until then, add it as a path or git dependency from credflare/flutter-sdk on GitHub.Add the guided flow
import 'package:credflare_sdk/credflare_sdk.dart';
CredflareVerification(
sessionProvider: () async {
final response = await api.post('/credflare/session'); // your backend
return SessionDescriptor.fromJson(response);
},
onClose: () => Navigator.of(context).pop(),
onSubmitted: (info) => refreshStatus(),
) sessionProvider calls your own authenticated backend, which creates the session as shown in the server example. SessionDescriptor.fromJson rejects a non-HTTPS API URL outside localhost.
| Parameter | Purpose |
|---|---|
sessionProvider | Returns a session descriptor from your backend. Required. |
onClose | Called when the applicant closes the flow or presses Done. Required. |
onSubmitted | Called once nothing is left to collect. It receives the session info, not a decision. |
onCancelled | Called when the applicant leaves before finishing. The case stays open. |
onHostActionRequired | Called with the rejection code before onClose when the applicant leaves from a leave rejection, so your app can follow up. |
autoStart | Skips the Start screen and loads the session at once. |
httpClient | An optional http.Client, for example to add your own logging or tests. |
livenessSource | Replaces the camera source for the liveness step. |
locationSource | Replaces the location source. |
After the documents, the flow asks the outstanding questions, then runs the case's facial, location, email and phone requirements in profile order, and shows a receipt once everything required is in. A questionnaire with a founders question returns control to your app.
Liveness and location
- The facial step requests a liveness challenge, runs its gestures on a mirrored front camera preview, keeps a frame per gesture, records a video without sound when the profile asks for one, then takes the selfie for the applicant to review before sending.
- Face signals come from Apple Vision on iOS and ML Kit face detection on Android, each in the plugin's own platform code behind a
FaceSignalProvider. The provider name sent with the evidence (visionormlkit) picks the spec thresholds. - The location step uses
geolocator.is_mockis the Android mock flag, and on iOS whether the system marks the fix as simulated by software. - A rejected capture throws
CredflareExceptionwith a stablecodefromSpecErrorCode. The guided screens show the rejection screen for each code, and a challenge code starts over with a new challenge. - For your own screens, the client has
createLivenessChallenge(),uploadBiometric,submitFacialandsubmitLocation.
Questions and codes
- Text, long text, number, date, email, phone, single and multiple choice, country and consent questions are supported. Questions with
show_ifappear and disappear as answers change. Hidden questions are not checked and not sent. - The email and phone steps send a code, take it, and enable a new code at the resend time from the server, with the number of codes left.
- After every submission or code confirmation, the flow loads the session again and follows the refresh rule.
- Every
email.*andphone.*rejection shows its rejection screen, with the requester's help contact as a mail link or a web link. - For your own screens:
requestContactCode(channel, destination),confirmContactCode(channel, code),submitAnswers(fields, key: ...)andquestionVisible(question, answers).Rejection.from(error, info: info)reads the screen for a code,CredflareRejectionshows it, andCredflareException.resendAvailableAtcarries the resend time of aresend_too_soonrejection.
Build your own screens
Use CredflareSessionController to load the session and CredflareDocumentCapture for one document. captureSteps(requirement), methodSummary(requirement) and isCaptureSupported(requirement) match the JavaScript helpers.
CredflareDocumentCapture(
session: session,
requirement: requirement,
requesterName: info['requester']?['name'],
maxFileSizeBytes: info['upload_limits']['max_file_size_bytes'],
allowedFileTypes: List<String>.from(info['upload_limits']['allowed_file_types']),
onSubmitted: (submissionId) => reloadRequirements(),
onDirtyChanged: (hasUnsentFiles) => guardLeave = hasUnsentFiles,
) To call the API directly, session.upload takes documentTypeId, side and source, and session.submit takes the same evidence list as the JavaScript client. Create keys with requestKey() and reuse them on retry.
Configure the app
- Dart 3.11 and Flutter 3.41 or newer, and iOS 15 or newer. The SDK adds no ML Kit pods on iOS, so the app runs on Apple silicon simulators.
- iOS
Info.plist:NSCameraUsageDescription,NSPhotoLibraryUsageDescriptionandNSLocationWhenInUseUsageDescription. No microphone permission is needed. - Android:
INTERNET,CAMERA,ACCESS_FINE_LOCATIONandACCESS_COARSE_LOCATION. The video has no sound, so you can remove theRECORD_AUDIOpermission the camera plugin declares, as the example app does. - Close the session client with
close()when you build your own screens; the guided flow does this for you.
Read how the SDKs work for capture methods, receipts and error handling.