Vlens liveness Mobile SDK

Introduction :

Vlens liveliness Package is a Flutter package that provides a simple and easy-to-use way to verify the liveliness of a user. The package takes 3 of these posses :

  1. Look Left: Turn to the left to initiate the verification process.

  2. Look Right: Turn to the right to initiate the verification process.

  3. Blink: A quick blink of your eyes confirms your presence.

  4. Smile: Flash a genuine smile to seal the deal.

and if the user succeed that will verify liveliness.

Installation:

#iOS

Add two rows to the ios/Runner/Info.plist file:

One with the key Privacy - Camera Usage Description and a usage description. If editing Info.plist as text, add: NSCameraUsageDescription your usage description here add:

<key>NSCameraUsageDescription</key>
<string>your usage description here</string>

#Android

Change the minimum Android SDK version to 21 (or higher) in your android/app/build.gradle file. minSdkVersion 21

Add the following permission to your app's manifest, located at android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET"/>

Copy the package file provided by vlens to your app folder.

Add the package in pubspec.yaml file under the dependencies :

dependencies:
  flutter:
    sdk: flutter 
  vlens: 
    path: packages/vlens_livness

Run the following command to install the package: flutter pub get

Once you have completed these steps, you will be able to use the VLens package in your Flutter app.

Example :

import 'package:flutter/material.dart';
import 'package:vlens_livness/vlens_livness.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key,});


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

class _MyHomePageState extends State<MyHomePage> {
  LivnessMultiModel select = LivnessMultiModel();
  TextEditingController accountNameController = TextEditingController();

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text("Vlens Livness"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Column(
              children: [
                ElevatedButton(onPressed: () async {
                  LivnessMultiModel  s = await Vlens.instance
                            .startVlensFlow(
                                context: context,
                                apiKey:
                                    "add your API key here",
                    transactionId: "add Transaction Id her"
                                );

                  setState(() {
                    select =  s;
                  });
                }, child:  Text(
                  'start livness',
                  style: Theme.of(context).textTheme.headlineMedium,
                ),
                ),
                select.data != null ?
                Column(
                    children: [
    Text("liveness :${select.data!.liveness !=null ?select.data!.liveness.toString(): "null"}"),
                      Text("isMatched :${select.data!.isMatched !=null ?select.data!.isMatched.toString(): "null"}"),
                      Text("detectedFaces :${select.data!.detectedFaces !=null ?select.data!.detectedFaces.toString(): "null"}"),
                      Text("detectedIdFace :${select.data!.detectedIdFace !=null ?select.data!.detectedIdFace.toString(): "null"}"),
                      Text("transactionId :${select.data!.transactionId ?? "null"}"),
                    ],
                  )
                    : SizedBox.shrink(),

                select.errorCode!=null? Text("errorCode :${select.errorCode }"): SizedBox.shrink(),
              ],
            )
          ],
        ),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

Last updated