face_camera 0.0.1
face_camera: ^0.0.1 copied to clipboard
A Flutter camera plugin that detects face in real-time.
example/lib/main.dart
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:face_camera/face_camera.dart';
void main() async{
WidgetsFlutterBinding.ensureInitialized();
await FaceCamera.intialize();
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
File? _capturedImage;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('FaceCapture example app'),
),
body: Builder(
builder: (context) {
if(_capturedImage!=null){
return Center(
child: Stack(
alignment: Alignment.bottomCenter,
children: [
Image.file(
_capturedImage!,
width: double.maxFinite,
fit: BoxFit.fitWidth,
),
ElevatedButton(
onPressed: ()=>setState(()=>_capturedImage=null),
child: const Text('Capture Again',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14,
fontWeight: FontWeight.w700),
)
)
],
),
);
}
return SmartFaceCamera(
defaultCameraLens: CameraLens.front,
message: 'Center your face in the sqaure',
autoCapture: true,
onCapture: (File? image){
setState(()=> _capturedImage=image);
},
);
}
)
),
);
}
}