mss_kyc 0.0.2
mss_kyc: ^0.0.2 copied to clipboard
A Flutter Plugin for scanning passports
example/lib/main.dart
import 'dart:io';
import 'package:flutter/material.dart';
import 'mss_ekyc_screen.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MainScreen(),
);
}
}
class MainScreen extends StatefulWidget {
const MainScreen({super.key});
@override
State<MainScreen> createState() => _MainScreenState();
}
class _MainScreenState extends State<MainScreen> {
File? _image;
Map<String,dynamic>? _scanResult;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('MSS EKYC SDK'),
),
body: Container(
width: double.infinity,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 8),
Text(
'Click on the button to start',
style: Theme.of(context).textTheme.bodyMedium,
),
const SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () async {
_start();
},
child: const Text('Start'),
),
const SizedBox(width: 8),
ElevatedButton(
onPressed: () async {
setState(() {
_scanResult = null;
});
},
child: const Text('Cancel'),)
],
),
const SizedBox(height: 8),
_scanResult!= null? Column(
children: [
Text('Document type: ${_scanResult!['document_type']}'),
Text('Country: ${_scanResult!['country_code']}'),
Text('Surnames: ${_scanResult!['surnames']}'),
Text('Given names: ${_scanResult!['given_names']}'),
Text('Document number: ${_scanResult!['document_number']}'),
Text('Nationality code: ${_scanResult!['nationality_code']}'),
Text('Birthdate: ${_scanResult!['birth_date']}'),
Text('Sex: ${_scanResult!['sex']}'),
Text('Expiry date: ${_scanResult!['expiry_date']}'),
Text('Personal number: ${_scanResult!['personal_number']}'),
Text('Personal number 2: ${_scanResult!['personal_number2']}'),
const SizedBox(height: 5),
Image.file(File(_scanResult!['image'])),
],
) : Container(),
],
),
),
),
);
}
_start() async {
final result = await Navigator.push(context,MaterialPageRoute(builder: (context) {
return MSSEkycScreen();
}));
if (result!= null) {
setState(() {
_scanResult = result;
});
}
}
}