intp_flutter_liveness_sdk 1.2.0 copy "intp_flutter_liveness_sdk: ^1.2.0" to clipboard
intp_flutter_liveness_sdk: ^1.2.0 copied to clipboard

outdated

The Flutter SDK built incorporates the view of the liveness detection video recording feature.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:intp_flutter_liveness_sdk/intp_flutter_liveness_sdk.dart';

Future<void> main() async {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Liveness detection'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  Future<String?> buildDialog(Map<String, dynamic> value) {
    debugPrint("_buildDialog: $value");

    String content = "Detection success !!!";

    if (!value['Liveness']['detectSuccess']) {
      content = "Detection failed !!!";
    }

    if (value['statusCode'] != null && value['statusCode'] != "200") {
      content = "Error code : ${value['statusCode']} ${value['errorMessage']}";
    }

    return showDialog<String>(
      context: context,
      builder: (BuildContext context) => AlertDialog(
        title: const Text('Result'),
        content: Text(content),
        actions: <Widget>[
          TextButton(
            onPressed: () => Navigator.pop(context, 'OK'),
            child: const Text('OK'),
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: SafeArea(
        child: LivenessCamera(
          livenessResponse: (Map<String, dynamic> value) {
            // handle your next event or navigation from below
            buildDialog(value);
          },
          endpoint: "API_ENDPOINT",
          apiKey: "API_KEY",
          // actionsInstruction: const {
          //   'SHAKE_LEFT': 'New caption turn your head left',
          //   'SHAKE_RIGHT': 'New caption turn your head right',
          //   'NOD_HEAD': "New caption nod your head",
          //   'MOUTH': "New caption open your mouth",
          // },
          // numberOfActions: 2,
          // numberOfRetry: 0,
          // backgroundColor: Colors.red,
          // fontFamily: "Roboto",
          // prepareText: "Position your face in the circle.",
          // prepareFontColor: Colors.amber,
          // prepareFontSize: 24,
          // loadingColor: Colors.amber,
          // loadingSize: 50.0,
          // buttonLabel: "Start",
          // buttonStyle: ElevatedButton.styleFrom(
          //   primary: Colors.red
          // ),
          // buttonPadding: EdgeInsets.all(100),
          // iconGalleryPath: "assets/images/image_gallery.svg",
        ),
      ),
    );
  }
}
1
likes
0
points
16
downloads

Publisher

unverified uploader

Weekly Downloads

The Flutter SDK built incorporates the view of the liveness detection video recording feature.

Homepage

License

unknown (license)

Dependencies

camera, dio, file_picker, flutter, flutter_svg, logger, plugin_platform_interface, video_player

More

Packages that depend on intp_flutter_liveness_sdk

Packages that implement intp_flutter_liveness_sdk