esign_plugin 1.0.16
esign_plugin: ^1.0.16 copied to clipboard
Digio Esign flutter plugin
example/lib/main.dart
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:esign_plugin/service_mode.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.SANDBOX;
digioConfig.serviceMode = ServiceMode.OTP;
final _esignPlugin = EsignPlugin(digioConfig);
_esignPlugin.setGatewayEventListener(gatewayFunnelEventCallback);
esignResult = await _esignPlugin.start(
"DID250117174131348NG49D51QXNV963", "[email protected]", "GWT2501171741317017Z4HNYSTEJ9U5S", 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: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: () {
initSign();
},
child: Text('Press Me'),
),
SizedBox(height: 20),
Text('response : $_response\n'),
],
),
),
),
);
}
}