new_face_authenticator 1.1.0 copy "new_face_authenticator: ^1.1.0" to clipboard
new_face_authenticator: ^1.1.0 copied to clipboard

Flutter plugin cross-platform (iOS, Android) for Combate à Fraude's FaceAuthenticator (https://github.com/combateafraude).

example/lib/main.dart

import 'package:new_face_authenticator/caf_stage.dart';
import 'package:new_face_authenticator/face_authenticator.dart';
import 'package:new_face_authenticator/result/face_authenticator_failure.dart';
import 'package:new_face_authenticator/result/face_authenticator_result.dart';
import 'package:new_face_authenticator/result/face_authenticator_success.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:permission_handler/permission_handler.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _result = "";
  String _description = "";

  String mobileToken = "";
  String peopleId = "";

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

    requestPermissions();
  }

  void requestPermissions() async {
    await [
      Permission.camera,
    ].request();
  }

  void startFaceAuthenticator() async {
    String result = "";
    String description = "";

    FaceAuthenticator faceAuthenticator =
        new FaceAuthenticator(mobileToken: mobileToken, personId: peopleId);

    faceAuthenticator.setStage(CafStage.DEV);
    // Put the others parameters here

    try {
      FaceAuthenticatorResult faceAuthenticatorResult =
          await faceAuthenticator.start();

      if (faceAuthenticatorResult is FaceAuthenticatorSuccess) {
        result = "Success!";

        description += "isMatch: " + faceAuthenticatorResult.isAlive.toString();
      } else if (faceAuthenticatorResult is FaceAuthenticatorFailure) {
        result = "Falha!";
        description = "Error Message: " + faceAuthenticatorResult.errorMessage!;
      } else {
        result = "Closed!";
      }
    } on PlatformException catch (err) {
      result = "Excpection!";
      description = err.message!;
    }

    if (!mounted) return;

    setState(() {
      _result = result;
      _description = description;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
            appBar: AppBar(
              title: const Text('FaceAuthenticator plugin example'),
            ),
            body: Container(
                margin: const EdgeInsets.all(20.0),
                child: Column(
                  children: [
                    Row(
                      children: [
                        ElevatedButton(
                          child: Text('Start FaceAuthenticator'),
                          onPressed: () async {
                            startFaceAuthenticator();
                          },
                        )
                      ],
                    ),
                    Row(
                      children: [
                        Container(
                            margin: EdgeInsets.only(top: 10.0),
                            child: Text("Result: $_result"))
                      ],
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Expanded(
                          child: Text("Description:\n$_description",
                              overflow: TextOverflow.clip),
                        )
                      ],
                    ),
                  ],
                ))));
  }
}
4
likes
0
pub points
74%
popularity

Publisher

unverified uploader

Flutter plugin cross-platform (iOS, Android) for Combate à Fraude's FaceAuthenticator (https://github.com/combateafraude).

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on new_face_authenticator