kyc_workflow 1.0.15 kyc_workflow: ^1.0.15 copied to clipboard
Digio kyc workflow plugin
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:kyc_workflow/digio_config.dart';
import 'package:kyc_workflow/environment.dart';
import 'package:kyc_workflow/gateway_event.dart';
import 'package:kyc_workflow/kyc_workflow.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _workflowResult = '';
@override
void initState() {
super.initState();
startKycWorkflow();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> startKycWorkflow() async {
var workflowResult;
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try {
var digioConfig = DigioConfig();
digioConfig.theme.primaryColor = "#32a83a";
digioConfig.logo =
"https://www.gstatic.com/mobilesdk/160503_mobilesdk/logo/2x/firebase_28dp.png";
digioConfig.environment = Environment.PRODUCTION;
final _kycWorkflowPlugin = KycWorkflow(digioConfig);
_kycWorkflowPlugin.setGatewayEventListener((GatewayEvent? gatewayEvent) {
print("gateway funnel event" + gatewayEvent.toString());
});
workflowResult = await _kycWorkflowPlugin.start(
"KID2411271647169999GY72S4LF3TGMN",
"akash.kumar@digio.in",
"GWT2411271647170306AM8HB58DXSTKS",
null
);
print('workflowResult : ' + workflowResult.toString());
} on PlatformException {
workflowResult = 'Failed to get platform version.';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_workflowResult = workflowResult.toString();
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('Result : $_workflowResult'),
),
),
);
}
}