注意:插件中未进行权限处理,需自行在flutter层面进行权限处理,需要以下权限:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
import 'package:face/face_detect_plugin.dart';
try {
bool result = await FaceDetectPlugin.activeOnLine("appid","sdkkey");
return result;
} catch (e) {
print(e.message);
}
import 'package:flutter/material.dart';
import 'package:face/face_detect_camera_view.dart';
class CameraView extends StatefulWidget {
@override
_CameraViewState createState() => _CameraViewState();
}
class _CameraViewState extends State<CameraView> {
FaceDetectCameraController faceController;
@override
void initState() {
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
body: Container(
width: double.infinity,
height: double.infinity,
child: FaceDetectCameraView(
showRectView: true,
faceViewCreatedCallback: (FaceDetectCameraController faceController) {
this.faceController = faceController
..faceDetectStreamListen((data) {
print(data.toString());
});
},
),
),
);
}
}