intp_flutter_liveness_sdk 1.0.2
intp_flutter_liveness_sdk: ^1.0.2 copied to clipboard
The Flutter SDK built incorporates the view of the liveness detection video recording feature.
example/lib/main.dart
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> {
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
Future<String?> _buildDialog(Map<String, dynamic> value) {
String content = "Success !!!";
if (!value['detectSuccess']) {
content = "Failed !!!";
}
if (value['statusCode'] != null && value['statusCode'] > 200) {
content = "Error ${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'),
),
],
),
);
}
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: SafeArea(
child: Container(
child: LivenessCamera(
apiKey: "API_KEY",
livenessResponse: (Map<String, dynamic> value) {
// handle your next event or navigation from below
_buildDialog(value);
},
// numberOfActions: 2,
// numberOfRetry: 1,
// backgroundColor: Colors.red,
// loadingColor: Colors.amber,
// loadingSize: 50.0,
// fontFamily: "",
// textColor: Colors.white,
// textSize: 50,
// buttonLabel: "Start",
// buttonStyle: ElevatedButton.styleFrom(
// primary: Colors.red
// ),
// buttonPadding: EdgeInsets.all(100),
),
),
),
);
}
}