kvalifika_sdk 1.0.26
kvalifika_sdk: ^1.0.26 copied to clipboard
Official Flutter plugin for integating Kvalifika SDK into your app.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:kvalifika_sdk/kvalifika_sdk.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
bool isGeorgian = false;
bool isSdkInitialize = false;
final String appLogo = "youtube";//"logo";
KvalifikaSdkLocale get locale {
if (isGeorgian) return KvalifikaSdkLocale.GE;
return KvalifikaSdkLocale.GE;
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Kvalifika'),
// actions: [
// Switch(
// value: isGeorgian,
// onChanged: (val) {
// setState(() {
// isGeorgian = val;
// });
// },
// ),
// ],
),
body: KvalifikaSdk(
// appId: "7bd2bab9-5bcb-4f8d-a0c8-d7fd3fd4653b", // Production21caf4ed-4240-4ef3-bba0-04257bedc835
// appId: "d4bb88d7-8e6d-4653-baef-9d87c1e102e6", // Development
// appId: "21caf4ed-4240-4ef3-bba0-04257bedc835",
appId: "ea6e02a1-dd89-40af-9d57-b07e1f742186", // client's id
// from -android sdk
development: false,
locale: locale,
logo: appLogo,
documentIcon: appLogo,
onInitialize: (context, sdk) {
setState(() {
isSdkInitialize = true;
});
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('SDK Initialized'),
),
);
sdk.startSession();
},
onStart: (context, sessionId) {
setState(() {
isSdkInitialize = true;
// counter++;
});
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Started Verification'),
),
);
},
onFinish: (context, sessionId) {},
onError: (context, error, message) {
print(error);
if (error == KvalifikaSdkError.TIMEOUT) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Timeout'),
),
);
}
if (error == KvalifikaSdkError.USER_CANCELLED) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('User Canceled'),
),
);
}
if (error == KvalifikaSdkError.USER_BLOCKED) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('The number of attempts has expired. User blocked for 5 minutes.'),
),
);
}
},
builder: (BuildContext context, KvalifikaSdk sdk) {
return Center(
child: Container(
margin: EdgeInsets.only(bottom: 40),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
isSdkInitialize
? SizedBox(
height: 120,
width: 120,
)
: SizedBox(
height: 120,
width: 120,
child: CircularProgressIndicator(),
),
Container(
margin: EdgeInsets.only(top: 20),
child: ElevatedButton(
key: const Key('start_session'),
onPressed: () {
if(isSdkInitialize) {
sdk.startSession();
}
},
child: Text('Start Verification'),
),
),
],
),
),
);
},
),
),
);
}
}