face_plugin.dart 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  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. //"android-license-0000-face-android", "idl-license.face-android"
  7. _channel.invokeMethod("initialize",
  8. {"licenseId": licenseId, "licenseFileName": licenseFileName}).catchError((error) {
  9. print("initialize:$error");
  10. });
  11. return this;
  12. }
  13. setFaceConfig(FaceConfig _config) {
  14. print(_config.toJson());
  15. _channel.invokeMethod("setFaceConfig", _config.toJson()).catchError((error) {
  16. print("setFaceConfig:$error");
  17. });
  18. }
  19. startFaceLiveness({Function data,Function onFailed}) {
  20. _channel.invokeMethod("startFaceLiveness").catchError((error) {
  21. print("startFaceLiveness:$error");
  22. onFailed.call(error);
  23. });
  24. EventChannel("plugin.bughub.dev/event").receiveBroadcastStream().listen((value) {
  25. data.call(value);
  26. }, onError: (error) {
  27. onFailed.call(error);
  28. });
  29. }
  30. }