Skip to content

ishaquehassan/document_scanner_flutter

Repository files navigation

document_scanner_flutter pub package

A document scanner + PDF generator plugin for Flutter. Supports Android and iOS with auto edge detection, cropping, B&W filter, and PDF generation.

Requirements

Platform Minimum Version
Android API 21 (Android 5.0)
iOS iOS 12.0
Flutter 3.0.0
Dart 2.17.0

Getting Started

Installing

document_scanner_flutter: ^0.4.0

Usage

Basic — Camera or Gallery picker

final File? scannedDoc = await DocumentScannerFlutter.launch(context);
// returns null if user cancels

Specific source

final File? scannedDoc = await DocumentScannerFlutter.launch(
  context,
  source: ScannerFileSource.CAMERA, // or ScannerFileSource.GALLERY
);

Re-edit an existing image (v0.4.0+)

final Uint8List imageBytes = await myFile.readAsBytes();

final File? rescanned = await DocumentScannerFlutter.launch(
  context,
  source: ScannerFileSource.CAMERA,
  initialImage: imageBytes,
  canBackToInitial: true,
);

Recover last scan after crash (v0.4.0+)

// Call this on app startup to recover image lost due to process death
final File? recovered = await DocumentScannerFlutter.retrieveLostData();
if (recovered != null) {
  // use recovered image
}

PDF generation from multiple scans

final File? pdfFile = await DocumentScannerFlutter.launchForPdf(
  context,
  source: ScannerFileSource.CAMERA,
);
// returns a PDF File or null if cancelled

Labels customization

final File? scannedDoc = await DocumentScannerFlutter.launch(
  context,
  source: ScannerFileSource.CAMERA,
  labelsConfig: {
    ScannerLabelsConfig.ANDROID_NEXT_BUTTON_LABEL: 'Next',
    ScannerLabelsConfig.ANDROID_SAVE_BUTTON_LABEL: 'Save',
    ScannerLabelsConfig.ANDROID_ROTATE_LEFT_LABEL: 'Rotate Left',
    ScannerLabelsConfig.ANDROID_ROTATE_RIGHT_LABEL: 'Rotate Right',
    ScannerLabelsConfig.ANDROID_ORIGINAL_LABEL: 'Original',
    ScannerLabelsConfig.ANDROID_BMW_LABEL: 'B & W',
    ScannerLabelsConfig.PICKER_CAMERA_LABEL: 'Camera',
    ScannerLabelsConfig.PICKER_GALLERY_LABEL: 'Gallery',
    ScannerLabelsConfig.PICKER_CANCEL_LABEL: 'Cancel',
    ScannerLabelsConfig.ANDROID_INITIAL_IMAGE_LOADING_MESSAGE: 'Loading image...',
  },
);

Changelog

See CHANGELOG.md for full release history.

About

A document scanner plugin for flutter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors