face_plugin.dart 966 B

123456789101112131415161718192021222324252627282930313233
  1. import 'package:flutter/services.dart';
  2. import 'face_config.dart';
  3. class FacePlugin {
  4. MethodChannel _channel = MethodChannel("plugin.bughub.dev/fltbdface");
  5. initialize({String licenseId, String licenseFileName}) {
  6. _channel.invokeMethod("initialize",
  7. {"licenseId": licenseId, "licenseFileName": licenseFileName}).catchError((error) {
  8. print("initialize:$error");
  9. });
  10. return this;
  11. }
  12. setFaceConfig(FaceConfig _config) {
  13. _channel.invokeMethod("setFaceConfig", _config.toJson()).catchError((error) {
  14. print("setFaceConfig:$error");
  15. });
  16. }
  17. startFaceLiveness({Function data,Function onFailed}) {
  18. _channel.invokeMethod("startFaceLiveness").catchError((error) {
  19. print("startFaceLiveness:$error");
  20. onFailed.call(error);
  21. });
  22. EventChannel("plugin.bughub.dev/event").receiveBroadcastStream().listen((value) {
  23. data.call(value);
  24. }, onError: (error) {
  25. onFailed.call(error);
  26. });
  27. }
  28. }