document_frame_scanner 0.0.2
document_frame_scanner: ^0.0.2 copied to clipboard
Capture and Crop your document images with a customizable camera interface using this flutter package.
example/lib/main.dart
import 'package:document_frame_scanner/document_frame_scanner.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: const HomeScreen(),
);
}
}
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Document Frame Scanner')),
body: Center(
child: ElevatedButton(
onPressed: () {
// Navigate to the DocumentFrameScanner screen when the button is pressed
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const DocumentFrameScannerExample()),
);
},
child: const Text('Start Document Capture'),
),
),
);
}
}
class DocumentFrameScannerExample extends StatelessWidget {
const DocumentFrameScannerExample({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: DocumentFrameScanner(
// Document frame dimensions
frameWidth: 614.4,
frameHeight: 387.3,
// Title displayed at the top
title: const Text(
'Capture Your Document',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
// Show Close button
showCloseButton: true,
// Callback when the document is captured
onCaptured: (imgPath) {
debugPrint('Captured image path: $imgPath');
},
// Callback when the document is saved
onSaved: (imgPath) {
debugPrint('Saved image path: $imgPath');
},
// Callback when the retake button is pressed
onRetake: () {
debugPrint('Retake button pressed');
},
// bottomFrameContainerChild: Container(
// color: Colors.red,
// child: Text('djdk'),
// ),
// Optional: Customize Capture button, Save button, etc. if needed
),
);
}
}