Package selection guidance compiled from public package information, community data, and project usage.
A Flutter plugin enabling document scanning on Android and iOS by leveraging Google's ML Kit Document Scanner API and Apple's VisionKit. It provides a seamless way to capture and detect document edges from images, automatically cropping and enhancing scanned documents. The plugin supports multiple platforms including Web, macOS, Windows, and Linux, making it ideal for cross-platform applications requiring document digitization. Built with ease of integration in mind, it simplifies the process of adding intelligent document scanning features without deep native code knowledge.
Use cases
Document digitization in mobile apps
Automated invoice and receipt scanning
Onboarding workflows with ID verification
PDF generation from scanned documents
Mobile banking and form processing
Key features
Uses ML Kit and VisionKit for accurate detection
Cross-platform support across all major OS
Simple API for image capture and processing
Automatic edge detection and cropping
Supports both Android and iOS with native performance
Suitable for
Developers building document-heavy apps
Startups needing fast onboarding
Apps requiring OCR-ready scans
Cross-platform teams using Flutter
Businesses automating paperwork
Considerations
Requires camera permissions on mobile devices
Performance may vary on older devices
Web support depends on browser capabilities
Limited customization of scan UI
Depends on external SDKs (ML Kit, VisionKit)
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
flutter_doc_scanner
A Flutter plugin for document scanning on Android, iOS, and Web using ML Kit Document Scanner API and VisionKit.
Example
Check out the example directory for a sample Flutter app using flutter_doc_scanner.
Document Scanner Demo
Screenshots
Features
High-quality and consistent user interface for digitizing physical documents.
Accurate document detection with precise corner and edge detection for optimal scanning results.
Flexible functionality allows users to crop scanned documents, apply filters, remove fingers, remove stains and other blemishes.
On-device processing helps preserve privacy.
Support for sending digitized files in PDF and JPEG formats back to your app.
Ability to set a scan page limit.
Support for image(png,jpeg) format and PDF has been added through various methods.
Fast single-picture scanning mode via useAutomaticSinglePictureProcessing for quick one-document captures.
Installation
To use this plugin, add flutter_doc_scanner as a dependency in your pubspec.yaml file.
Use the following function for document scanning on Android and iOS:
Future<void> scanDocument() async {
//by default way they fetch pdf for android and png for iOSdynamic scannedDocuments;
try {
scannedDocuments = awaitFlutterDocScanner().getScanDocuments(page: 3) ??
'Unknown platform documents';
} onPlatformException {
scannedDocuments = 'Failed to get scanned documents.';
}
print(scannedDocuments.toString());
}
Note-: If you want to obtain only a PDF scanned document, call getScannedDocumentAsPdf(). Similarly, if you want to get a scanned document in image format, use getScannedDocumentAsImages().
Android result payloads
getScanDocuments / getScannedDocumentAsPdf: returns a map with pdfUri and pageCount.
getScannedDocumentAsImages / getScanDocumentsUri: returns a map with images (list of page URIs) and count (also exposed via legacy Uri / Count keys for backwards compatibility).
Project Setup
Follow the steps below to set up your Flutter project on Android, iOS, and Web.
Android
Minimum Version Configuration
Ensure you meet the minimum version requirements to run the application on Android devices.
In the android/app/build.gradle file, verify that minSdkVersion is at least 21. This setting specifies the minimum Android API level required to run your app, ensuring compatibility with a wide range of Android devices.
Ensure you meet the minimum version requirements to run the application on iOS devices.
In the ios/Podfile file, make sure the iOS platform version is at least 13.0. This setting specifies the minimum iOS version required to run your app, ensuring compatibility with a wide range of iOS devices.
platform :ios, '13.0'
Permission Configuration
Add a String property to the app's Info.plist file with the key NSCameraUsageDescription and the value as the description for why your app needs camera access. This step is required by Apple to explain to users why the app needs access to the camera, and it's crucial for App Store approval.
The permission_handler dependency used by flutter_doc_scanner uses macros to control whether a permission is enabled. To enable camera permission, add the following to your Podfile file. This step ensures that your app can request and handle camera permissions on iOS devices:
post_install do |installer|
installer.pods_project.targets.each do |target|
... # Here are some configurations automatically generated by flutter
# Start of the permission_handler configuration
target.build_configurations.each do |config|
# You can enable the permissions needed here. For example, to enable camera
# permission, just remove the `#` character in front so it looks like this:
#
# ## dart: PermissionGroup.camera
# 'PERMISSION_CAMERA=1'
#
# Preprocessor definitions can be found at: https://github.com/Baseflow/flutter-permission-handler/blob/master/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## dart: PermissionGroup.camera
'PERMISSION_CAMERA=1',
]
end
# End of the permission_handler configuration
end
end
Web
Currently, we have removed web support for this library. For document scanning on the web, you can use the following library: flutter_doc_scanner_web.
Issues and Feedback
Please file issues to send feedback or report a bug. Thank you!
License
The MIT License (MIT) Copyright (c) 2024 Shirsh Shukla
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.