myid_reader 1.0.0 copy "myid_reader: ^1.0.0" to clipboard
myid_reader: ^1.0.0 copied to clipboard

MyIdReader SDK plugin for Flutter. Package supports iOS and Android to verify document identity.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:myid_reader/myid_reader_enums.dart';
import 'package:myid_reader/myid_reader.dart';
import 'package:myid_reader/myid_reader_config.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? _error;
  MyIdReaderResult? _result;

  Future<void> init() async {
    String? error;
    MyIdReaderResult? result;

    try {
      final idResult = await MyIdReaderClient.start(config: MyIdReaderConfig(
        locale: MyIdReaderLocale.english,
      ));

      error = null;
      result = idResult;
    } catch (e) {
      error = e.toString();
      result = null;
    }

    // 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(() {
      _error = error;
      _result = result;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('MyIdReader Sample'),
        ),
        body: Center(
          child: Column(
            children: [
              MaterialButton(
                onPressed: init,
                child: const Text('Start SDK'),
              ),
              Text(_result?.pinfl ?? _error ?? 'Failure'),
              Text(_result?.document ?? _error ?? 'Failure'),
              Text(_result?.firstName ?? _error ?? 'Failure'),
              Text(_result?.lastName ?? _error ?? 'Failure'),
              Text(_result?.expiryDate ?? _error ?? 'Failure'),
              Text(_result?.birthDate ?? _error ?? 'Failure'),
              Text(_result?.mrz ?? _error ?? 'Failure'),
              Text(_result?.selfie?.length.toString() ?? _error ?? 'Failure'),
              Text(_result?.documentFace?.length.toString() ?? _error ?? 'Failure'),
              Text(_result?.documentFront?.length.toString() ?? _error ?? 'Failure'),
              Text(_result?.documentBack?.length.toString() ?? _error ?? 'Failure'),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
130
points
15
downloads

Publisher

unverified uploader

Weekly Downloads

MyIdReader SDK plugin for Flutter. Package supports iOS and Android to verify document identity.

Repository
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on myid_reader