Skip to main content
vouchmark_widget is a Dart package that renders the Vouchmark verification flow inside a native WebView (webview_flutter), bridging events back to Dart through a JavaScript channel.

Installation

Add the package with the Flutter CLI:
flutter pub add vouchmark_widget
This adds vouchmark_widget to your pubspec.yaml (current version 1.0.0).

Platform setup

Android — set minSdkVersion 21 in android/app/build.gradle. iOS — requires iOS 13+. Add camera permissions to ios/Runner/Info.plist:
<key>NSCameraUsageDescription</key>
<string>Camera is required for identity verification</string>

Quick start

import 'package:vouchmark_widget/vouchmark_widget.dart';

class KybScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return VouchmarkWidget(
      widgetId: 'wgt_your_widget_id',
      publicKey: 'live_pk_your_public_key',
      environment: VouchmarkEnvironment.live,
      applicant: VouchmarkApplicant(
        email: 'applicant@example.com',
        businessName: 'Acme Ltd',
        registrationNumber: 'RC123456',
      ),
      onSuccess: (applicant) {
        Navigator.of(context).pushReplacementNamed('/dashboard');
      },
      onAbandon: () {
        Navigator.of(context).pop();
      },
      onError: (error) {
        ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(content: Text('Error: ${error.message}')),
        );
      },
    );
  }
}

Configuration

VouchmarkWidget parameters

ParameterTypeRequiredDescription
widgetIdStringYesWidget ID from the dashboard. Must match the widget’s environment.
publicKeyStringYesPublishable key: test_pk_… (sandbox) or live_pk_… (live).
environmentVouchmarkEnvironmentYes.sandbox with test_pk_…, .live with live_pk_…. See Environments.
applicantVouchmarkApplicant?NoPre-fill applicant details.
referenceIdString?NoYour internal reference.
sessionTokenString?NoSigned server token for secure mode.
localeString?NoLanguage code. Default "en".
onSuccessvoid Function(VouchmarkResult)NoCalled on approval.
onAbandonVoidCallback?NoCalled when user closes.
onErrorvoid Function(VouchmarkError)?NoCalled on error.
onStepCompletedvoid Function(VouchmarkStep)?NoCalled after each module.
Call showVouchmarkModal to push the widget as a full-screen dialog route. It returns a Future<VouchmarkResult?> that resolves with the result when verification succeeds, or null if the user dismisses it:
Future<void> _startKyb(BuildContext context) async {
  final result = await showVouchmarkModal(
    context: context,
    widgetId: 'wgt_...',
    publicKey: 'live_pk_...',
    environment: VouchmarkEnvironment.live,
    onSuccess: (result) {
      // optional inline callback; the result is also returned by the Future
    },
  );

  if (result != null) {
    // handle approval
  }
}

Models

enum VouchmarkEnvironment { sandbox, live }

class VouchmarkApplicant {
  final String? email;
  final String? businessName;
  final String? registrationNumber;
  final String? phone;
  final String? tin;
  final String? jurisdiction;
  final String? industry;
}

class VouchmarkResult {
  final String id;
  final String status; // "approved", "rejected", "requires_review"
  final double? riskScore;
  final String? decisionReason;
}

class VouchmarkError {
  final String code;
  final String message;
}

class VouchmarkStep {
  final String moduleId;
  final String status; // "passed", "failed", "requires_review"
}

Signed sessions

Generate the session token on your backend and pass it to the widget:
// Fetch token from your server
final response = await http.post(
  Uri.parse('https://your-api.com/kyb-session'),
  body: jsonEncode({'email': 'applicant@example.com'}),
);
final token = jsonDecode(response.body)['token'];

// Pass to widget
VouchmarkWidget(
  widgetId: 'wgt_...',
  publicKey: 'live_pk_...',
  environment: VouchmarkEnvironment.live,
  sessionToken: token,
  onSuccess: (result) { /* ... */ },
);

Platform support

PlatformMinimum version
AndroidAPI 21 (5.0)+
iOS13.0+