enroll_plugin 1.5.0
enroll_plugin: ^1.5.0 copied to clipboard
eNROLL is a compliance solution that prevents identity fraud and phishing. Powered by AI, it reduces errors and speeds up identification, ensuring secure verification.
import 'package:enroll_plugin/enroll_plugin.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
/// Example theme demonstrating typography + JSON localization overrides.
///
/// Android setup:
/// - Keep `enroll_localizations_en.json` and `enroll_localizations_ar.json`
/// under `example/android/app/src/main/assets/`.
///
/// iOS host-app setup required for this to take visible effect:
/// - Register `Farah.ttf` (or your preferred font) under `UIAppFonts` in
/// `example/ios/Runner/Info.plist` and add the file to the Runner target's
/// "Copy Bundle Resources" build phase.
/// - Add `enroll_localizations_en.json` and `enroll_localizations_ar.json`
/// to the Runner bundle (also via "Copy Bundle Resources").
///
/// Android loads each file from app assets. iOS loads each file from
/// `Bundle.main` by name. Each native SDK applies it as a localization
/// override for the matching language.
final EnrollTheme _typographyTheme = EnrollTheme(
colors: EnrollColors(
primary: const Color(0xFF1D56B8),
secondary: const Color(0xFF5791DB),
),
typography: const EnrollTypography(
fontFamily: 'Farah',
dynamicTypeEnabled: true,
sizes: EnrollFontSizes.large,
localizationOverrides: EnrollLocalizationOverrides(
englishFileName: 'enroll_localizations_en',
arabicFileName: 'enroll_localizations_ar',
),
),
);
/// Example theme combining custom colors and icons.
///
/// To use custom icons, add PNG/XML drawables to:
/// example/android/app/src/main/res/drawable/
/// Then reference them by name (without extension) in [EnrollStepIcon.assetName].
// ignore: unused_element
final EnrollTheme _exampleTheme = EnrollTheme(
colors: EnrollColors(
primary: const Color(0xFF756C10),
secondary: const Color(0xFF192537),
),
icons: const EnrollIcons(
logo: EnrollLogoConfig(
mode: EnrollLogoMode.custom,
assetName: 'sample_location_icon',
renderingMode: EnrollIconRenderingMode.original,
),
location: EnrollLocationIcons(
tutorial: EnrollStepIcon(
assetName: 'sample_location_icon',
renderingMode: EnrollIconRenderingMode.original,
),
),
faceMatching:
EnrollFaceMatchingIcons(tutorial: EnrollStepIcon(assetName: "")),
nationalId: EnrollNationalIdIcons(
tutorial: EnrollStepIcon(
assetName: 'sample_location_icon',
renderingMode: EnrollIconRenderingMode.original,
),
tutorialIdOrPassport: EnrollStepIcon(
assetName: 'sample_location_icon',
renderingMode: EnrollIconRenderingMode.original,
),
),
common: EnrollCommonIcons(
termsAndConditions: EnrollStepIcon(
assetName: 'enroll_example_terms',
renderingMode: EnrollIconRenderingMode.original,
),
popups: EnrollPopupIcons(
successIcon: EnrollStepIcon(
assetName: 'enroll_example_success',
renderingMode: EnrollIconRenderingMode.original,
),
),
),
),
);
/// My App
class MyApp extends StatefulWidget {
/// My App constructor
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(home: Builder(builder: (context) {
return Scaffold(
body: EnrollPlugin(
mainScreenContext: context,
tenantId: 'TENANT_ID',
tenantSecret: 'TENANT_SECRET',
requestId: 'REQUEST_ID',
enrollMode: EnrollMode.onboarding,
enrollEnvironment: EnrollEnvironment.staging,
onSuccess: (applicantId) {
WidgetsBinding.instance.addPostFrameCallback((_) {
debugPrint("success: $applicantId");
});
},
onError: (error) {
WidgetsBinding.instance.addPostFrameCallback((_) {
debugPrint("Error: ${error.toString()}");
});
},
onGettingRequestId: (requestId) {
WidgetsBinding.instance.addPostFrameCallback((_) {
debugPrint("requestId:: $requestId");
});
},
localizationCode: EnrollLocalizations.ar,
applicationId: '',
skipTutorial: false,
levelOfTrust: 'LEVEL_OF_TRUST_TOKEN',
googleApiKey: 'GOOGLE_API_KEY',
correlationId: 'correlationIdTest',
templateId: "templateId",
contractParameters: "contractParameters",
// appColors: EnrollColors(
// primary: Color(0xFF756C10),
// secondary: Color(0xFF192537),
// appBlack: Color(0xFF000000),
// appWhite: Color(0xFFFFFFFF),
// ),
// enrollTheme: _exampleTheme,
// Demonstrates EnrollTypography + JSON localization overrides.
enrollTheme: _typographyTheme,
// enrollExitStep: EnrollStepType.personalConfirmation,
),
);
}));
}
}