main.dart 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. data: (data) {
  29. print(data);
  30. },
  31. onFailed: (error) {
  32. print(error);
  33. });
  34. },
  35. child: Text("点击采集人脸"),
  36. ),
  37. ),
  38. ),
  39. );
  40. }
  41. }