smt_face_ml_kit 0.0.11
smt_face_ml_kit: ^0.0.11 copied to clipboard
mlkit人脸识别项目,安卓使用google mlkit ,ios使用apple mlkit
example/lib/main.dart
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:smt_face_ml_kit/smt_camera_view.dart';
import 'package:smt_face_ml_kit/smt_face_ml_kit.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
Uint8List? _image;
bool isStart = false;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Stack(
alignment: Alignment.center,
children: [
Container(
width: double.infinity,
height: double.infinity,
child: isStart == false
? Container(
color: Colors.green,
)
: SMTCameraView(),
),
Column(
mainAxisSize: MainAxisSize.min,
children: [
MaterialButton(
onPressed: () async {
await SmtFaceMlKit.startFaceMlKit(
facesList: (faces) {
print("faces:$faces");
},
lightValue: (light) {
print("light:$light");
},
errorMsg: (error) {
print("error:$error");
},
isNeedView: true);
setState(() {
isStart = true;
});
},
child: Text("开始检测"),
),
MaterialButton(
onPressed: () {
SmtFaceMlKit.endFaceMlKit();
setState(() {
isStart = false;
});
},
child: Text("结束检测"),
),
],
),
],
),
),
);
}
}