esign_plugin 1.0.0 esign_plugin: ^1.0.0 copied to clipboard
Digio Esign flutter plugin
import 'dart:async';
import 'package:esign_plugin/digio_config.dart';
import 'package:esign_plugin/environment.dart';
import 'package:esign_plugin/esign_plugin.dart';
import 'package:esign_plugin/gateway_event.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.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 _response = '';
@override
void initState() {
super.initState();
initSign();
}
void gatewayFunnelEventCallback(GatewayEvent? map){
print("gateway funnel event" + map.toString());
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initSign() async {
var esignResult;
// 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 _esignPlugin = EsignPlugin(digioConfig);
_esignPlugin.setGatewayEventListener(gatewayFunnelEventCallback);
esignResult = await _esignPlugin.start(
"DID220824180502253BSD9WM89CP25CZ", "omprakash@digio.in", "", null);
print('esignResult : ' + esignResult.toString());
} on PlatformException {
esignResult = '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(() {
_response = esignResult.toString();
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('response : $_response\n'),
),
),
);
}
}