kyc_workflow 2.0.6 copy "kyc_workflow: ^2.0.6" to clipboard
kyc_workflow: ^2.0.6 copied to clipboard

Digio kyc workflow plugin

example/lib/main.dart

import 'dart:async';
import 'dart:collection';

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';
import 'package:kyc_workflow/service_mode.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;
      digioConfig.serviceMode = ServiceMode.OTP;

      final _kycWorkflowPlugin = KycWorkflow(digioConfig);
      _kycWorkflowPlugin.setGatewayEventListener((GatewayEvent? gatewayEvent) {
        print("gateway funnel event ${gatewayEvent?.event}");
      });

      HashMap<String, String> additionalData = HashMap<String, String>();
      // additionalData["dg_disable_upi_collect_flow"] = "false"; // optional for mandate

      workflowResult = await _kycWorkflowPlugin.start(
          "KID250516123234409NIBZ9QLFJ57GJX",
          "akash.kumar@digio.in",
          "GWT250516123234446JKJKWWHXB6ON6S",
          additionalData
      );
      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: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('Result: $_workflowResult'),
              SizedBox(height: 10),
              // Text('Event: $_workflowEvent'),
            ],
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: startKycWorkflow, // Your function to call
          child: Icon(Icons.play_arrow), // or any icon you like
          tooltip: 'Start Workflow',
        ),
      ),
    );
  }
}
5
likes
130
points
2.33k
downloads

Publisher

unverified uploader

Weekly Downloads

Digio kyc workflow plugin

Homepage

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on kyc_workflow