faceidverify 0.0.2
faceidverify: ^0.0.2 copied to clipboard
Face ID Scanner and Verify App
FaceID Verify #
A Flutter package for face scanning and face verification using the device camera.
It captures face data and compares it with previously stored face data.
Installation #
Add the package to your pubspec.yaml.
dependencies:
faceidverify: ^last_version
Then run:
flutter pub get
Permissions #
Android #
Add camera permission to:
android/app/src/main/AndroidManifest.xml
<uses-permission android:name="android.permission.CAMERA"/>
iOS #
Add camera usage description to:
ios/Runner/Info.plist
<key>NSCameraUsageDescription</key>
<string>Camera permission is required for face verification</string>
Usage #
1. Register Face #
Use FaceScanner to capture face data from the user.
FaceScanner(
onScanCompleted: (faces) {
if (faces == null) return;
// faces -> List<String>
// Save this to your database or API
print(faces);
},
)
Returned data:
List<String>
These values represent the user's face data and should be stored.
2. Verify Face #
Use stored face data to verify the user.
FaceVerify(
faceDatas: storedFaces,
onVerifyCompleted: (result) {
if (result) {
print("Verification successful");
} else {
print("Verification failed");
}
},
)
Full Example #
class FaceExamplePage extends StatefulWidget
{
const FaceExamplePage({super.key});
@override
State<FaceExamplePage> createState() => _FaceExamplePageState();
}
class _FaceExamplePageState extends State<FaceExamplePage>
{
List<String>? faces;
@override
Widget build(BuildContext context)
{
return Scaffold(
appBar: AppBar(title: const Text("FaceID Example")),
body: faces == null
? FaceScanner(
onScanCompleted: (data)
{
setState(()
{
faces = data;
});
},
)
: FaceVerify(
faceDatas: faces!,
onVerifyCompleted: (result)
{
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(result ? "Success" : "Failed"),
),
);
},
),
);
}
}
Services #
FaceScanner #
Responsible for:
- Opening the camera
- Performing a liveness check
- Generating multiple face samples
- Returning the result through
onScanCompleted
Return type:
List<String>
This represents the user's face data.
FaceVerify #
Responsible for:
- Opening the camera
- Creating new face data
- Comparing with stored data
- Returning the verification result
Callback:
onVerifyCompleted(bool result)
FaceIdService #
Handles all internal processing.
Responsibilities:
- Face detection
- Face data generation
- Liveness detection
- Face comparison
Both widgets use this service internally.
Flow #
FaceScanner
↓
face data generated
↓
stored in database
↓
FaceVerify
↓
user verified
Customization #
Some parameters can be customized.
FaceVerify(
scanSteps: 5,
threshold: 0.75,
width: 320,
)