Flutter package for capturing vehicle registration documents (ruhsat) using the device camera with ML-based auto-detection. The package uses Google ML Kit Text Recognition to detect the document in the camera frame and automatically captures the photo when the document is stable.
Camera Screen Auto-Capture
- Auto-detection: Recognizes Turkish vehicle registration documents (ruhsat) via keyword matching using Google ML Kit OCR.
- Auto-capture: Automatically takes a photo after the document has been steadily detected for a configurable duration.
- Manual capture: Optional manual shutter button for fallback capture.
- Overlay frame: Customizable frame overlay with corner accents, center divider, and page labels (1. Sayfa / 2. Sayfa).
- Fully configurable: Detection keywords, frame appearance, timing, and UI texts are all customizable via
RuhsatCaptureConfig. - BLoC-based state management: Uses
flutter_blocfor clean state handling.
- Flutter SDK
>=3.8.0 - Camera permission must be granted before navigating to the capture screen.
- This package uses google_ml_kit for text recognition. Please review the full requirements for platform-specific setup.
minSdkVersion: 21targetSdkVersion: 35compileSdkVersion: 35
In your android/app/build.gradle:
android {
compileSdkVersion 35
defaultConfig {
minSdkVersion 21
targetSdkVersion 35
}
}Add camera permission to android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.CAMERA" />- Minimum iOS Deployment Target: 15.5
- Xcode 15.3.0 or newer
- Swift 5
- ML Kit does not support 32-bit architectures (i386 and armv7). You need to exclude armv7 in Xcode: Project > Runner > Build Settings > Excluded Architectures > Any SDK > armv7
Update your ios/Podfile:
platform :ios, '15.5' # or newer version
# add this line:
$iOSVersion = '15.5' # or newer version
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=*]"] = "armv7"
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
end
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
if Gem::Version.new($iOSVersion) > Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
end
end
end
endAdd camera permission to ios/Runner/Info.plist:
<key>NSCameraUsageDescription</key>
<string>Ruhsat fotoğrafı çekmek için kamera izni gereklidir.</string>Add the package to your pubspec.yaml:
dependencies:
ruhsat_capture:
path: ruhsat_captureRepository icinde tum ozellikleri kullanan bir ornek uygulama bulunur:
cd example
flutter pub get
flutter runOrnek uygulama icinde asagidaki tum konfig ayarlari canli olarak degistirilebilir:
RuhsatCaptureTextsRuhsatFrameConfigRuhsatCaptureTimingConfigDetectionKeywordsautoCaptureveshowManualCapture
import 'package:ruhsat_capture/ruhsat_capture.dart';
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => RuhsatCaptureScreen(
onCapture: (file) {
// file is an XFile — handle the captured image
debugPrint('Captured: ${file.path}');
},
),
),
);Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => RuhsatCaptureScreen(
config: const RuhsatCaptureConfig(
autoCapture: true,
showManualCapture: true,
texts: RuhsatCaptureTexts(
title: 'Ruhsat Çekimi',
instructionText: 'Ruhsatınızı çerçeve içine yerleştirin',
),
frame: RuhsatFrameConfig(
frameAspectRatio: 1.6,
activeBorderColor: Colors.green,
),
cameraResolutionPreset: ResolutionPreset.veryHigh,
preferWideAngleLens: true,
initialZoom: 1.0,
cropCapturedImageToFrame: true,
frameCropPaddingRatio: 0.08,
timing: RuhsatCaptureTimingConfig(
holdDuration: Duration(milliseconds: 1500),
captureDelay: Duration(milliseconds: 500),
),
keywords: DetectionKeywords(
required: ['şase', 'motor', 'plaka', 'marka', 'model'],
bonus: ['tescil', 'ruhsat', 'araç'],
minRequiredMatches: 3,
),
),
onCapture: (file) {
// Handle captured file
},
),
),
);The main widget. Push it as a full-screen route.
| Parameter | Type | Description |
|---|---|---|
config |
RuhsatCaptureConfig |
Configuration options (optional). |
onCapture |
void Function(XFile) |
Callback when a photo is captured. |
| Property | Type | Default |
|---|---|---|
texts |
RuhsatCaptureTexts |
Turkish defaults |
frame |
RuhsatFrameConfig |
White border, green active |
keywords |
DetectionKeywords |
Turkish ruhsat keywords |
timing |
RuhsatCaptureTimingConfig |
1.2s hold, 0.5s delay |
autoCapture |
bool |
true |
showManualCapture |
bool |
true |
cameraResolutionPreset |
ResolutionPreset |
ResolutionPreset.veryHigh |
preferWideAngleLens |
bool |
true |
initialZoom |
double |
1.0 |
enableAutoFocus |
bool |
true |
enableAutoExposure |
bool |
true |
cropCapturedImageToFrame |
bool |
true |
frameCropPaddingRatio |
double |
0.08 |
Controls which OCR keywords trigger document detection. Configure required and bonus keyword lists with match thresholds.
Controls the overlay frame appearance: aspect ratio, corner radius, border colors, center divider, and page labels.
Controls auto-capture timing: holdDuration (how long document must be visible) and captureDelay (delay before taking photo).
| Package | Version |
|---|---|
camera |
^0.11.2+1 |
google_ml_kit |
^0.21.0 |
flutter_bloc |
^9.1.0 |
equatable |
^2.0.7 |
This project is licensed under the MIT License — see the LICENSE file for details.

