mnc_identifier_ocr 1.0.11 mnc_identifier_ocr: ^1.0.11 copied to clipboard
MNC Flutter plugin KTP scanner for iOS and Android.
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:mnc_identifier_ocr/mnc_identifier_ocr.dart';
import 'package:mnc_identifier_ocr/model/ocr_result_model.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
OcrResultModel? result;
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> scanKtp() async {
OcrResultModel? res;
try {
res = await MncIdentifierOcr.startCaptureKtp(
withFlash: true, cameraOnly: true);
} catch (e) {
debugPrint('something goes wrong $e');
}
if (!mounted) return;
setState(() {
result = res;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Stack(
children: [
Text('Ktp data: ${result?.toJson()}'),
Center(
child: ElevatedButton(
onPressed: scanKtp, child: const Text('PUSH HERE')))
],
),
),
);
}
}