main.dart 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import 'package:fltbdface_example/face_service.dart';
  2. import 'package:flutter/material.dart';
  3. import 'dart:async';
  4. import 'package:flutter/services.dart';
  5. import 'package:fltbdface/fltbdface.dart';
  6. void main() => runApp(MyApp());
  7. class MyApp extends StatefulWidget {
  8. @override
  9. _MyAppState createState() => _MyAppState();
  10. }
  11. class _MyAppState extends State<MyApp> {
  12. FaceService faceService = FaceService();
  13. @override
  14. void initState() {
  15. super.initState();
  16. }
  17. @override
  18. Widget build(BuildContext context) {
  19. return MaterialApp(
  20. home: Scaffold(
  21. appBar: AppBar(
  22. title: const Text('Plugin example app'),
  23. ),
  24. body: Center(
  25. child: RaisedButton(
  26. onPressed: () {
  27. faceService.startFaceLiveness(
  28. withMouth: true,
  29. data: (data) {
  30. print(data);
  31. },
  32. onFailed: (error) {
  33. print(error);
  34. });
  35. },
  36. child: Text("点击采集人脸"),
  37. ),
  38. ),
  39. ),
  40. );
  41. }
  42. }