acuant_flutter 0.0.5 copy "acuant_flutter: ^0.0.5" to clipboard
acuant_flutter: ^0.0.5 copied to clipboard

Flutter plugin for Acuant Camera (Android only)

example/lib/main.dart

import 'package:acuant_flutter_example/acuant_key.dart';
import 'package:flutter/material.dart';
import 'package:acuant_flutter/acuant_flutter.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: "Test",
      home: MyPage(),
    );
  }
}

class MyPage extends StatefulWidget {
  const MyPage({Key? key}) : super(key: key);

  @override
  State<MyPage> createState() => _MyPageState();
}

class _MyPageState extends State<MyPage> {
  // String _platformVersion = 'Unknown';
  // final _acuantFlutterPlugin = Acuant();

  AcuantDocumentImage? acuantDocumentImage;
  AcuantFaceImage? acuantFaceImage;

  @override
  void initState() {
    super.initState();
  }

  void initAcuant() async {
    bool res = await Acuant.instance.initialize(
      username: kAcuantUsername,
      password: kAcuantPassword,
    );
    print(res);
  }

  void showDocumentCamera({bool isBack = false}) async {
    setState(() {
      acuantDocumentImage = null;
    });
    try {
      final res = await Acuant.instance.showDocumentCamera(isBack: isBack);
      print(res);
      if (res is AcuantDocumentImage) {
        setState(() {
          acuantDocumentImage = res;
        });
      }
    } on PlatformException catch (e) {
      showDialog(
          context: context,
          builder: (BuildContext context) {
            return AlertDialog(
              title: const Text("Error"),
              content: Text(e.message ?? "An error has occured"),
            );
          });
    } catch (e) {
      print(e);
    }
  }

  void showFaceCamera() async {
    try {
      setState(() {
        acuantFaceImage = null;
      });
      final res = await Acuant.instance.showFaceCamera();
      print(res);
      if (res is AcuantFaceImage) {
        setState(() {
          acuantFaceImage = res;
        });
      }
    } on PlatformException catch (e) {
      showDialog(
          context: context,
          builder: (BuildContext context) {
            return AlertDialog(
              title: const Text("Error"),
              content: Text(e.message ?? "An error has occurred"),
            );
          });
    } catch (e) {
      print(e);
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body: SingleChildScrollView(
        child: Padding(
          padding: const EdgeInsets.all(32),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              ElevatedButton(
                onPressed: initAcuant,
                child: const Text('initialize'),
              ),
              ElevatedButton(
                onPressed: showDocumentCamera,
                child: const Text('showDocumentCamera'),
              ),
              ElevatedButton(
                onPressed: () => showDocumentCamera(isBack: true),
                child: const Text('showDocumentCamera Back'),
              ),
              ElevatedButton(
                onPressed: showFaceCamera,
                child: const Text('showFaceCamera'),
              ),
              if (acuantDocumentImage != null) ...[
                Image.memory(acuantDocumentImage!.rawBytes),
                Text("Aspect ${acuantDocumentImage!.aspectRatio}"),
                Text("DPI ${acuantDocumentImage!.dpi}"),
                Text("Glare ${acuantDocumentImage!.glare}"),
                Text(
                    "isCorrectAspectRatio ${acuantDocumentImage!.isCorrectAspectRatio}"),
                Text("isPassport ${acuantDocumentImage!.isPassport}"),
                Text("Sharpness ${acuantDocumentImage!.sharpness}"),
              ],
              if (acuantFaceImage != null) ...[
                Image.memory(acuantFaceImage!.rawBytes),
                Text("Liveness ${acuantFaceImage!.liveness}"),
              ]
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
140
points
22
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter plugin for Acuant Camera (Android only)

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

acuant_platform_interface, flutter

More

Packages that depend on acuant_flutter