Web Document Scanner
A Flutter Package to Scan Document on WEB.
Contents:
Getting Started
Add dependencies in the pubspec.yaml:
dependencies:
web_document_scanner: ^latest
Get the Changes by:
flutter pub get
or
dart pub get
Usage
import 'package:web_document_scanner/web_document_scanner.dart';
Controller must be initialized:
void _controllerInitialization() async {
scannerStatus = ScannerStatus.initializing;
final List<CameraDescription> cameras = await availableCameras();
if (cameras.isNotEmpty) {
final CameraDescription selectedCamera = cameras.first;
scannerController = ScannerController(description: selectedCamera);
if (scannerController != null) {
await scannerController?.initialize();
} else {
throw Exception(PackageStrings.throwErrorControllerInitialization);
}
} else {
throw Exception(PackageStrings.throwErrorCameraAvailability);
}
}
Controller Can be Initialized in page initialization OR triggered by a trigger such as tapping on a Button:
void onInit() {
_controllerInitialization();
super.initState();
}
OR
Button(onPressed: () => _controllerInitialization(), child: Text('Controller Initialization'));
NOTE: In either way,
Controllermust be initialized before havingScannerWidget.
Using Scanner Widget in your Screen:
WebDocumentScanner(scannerController!);
Controller will return the Captured Document:
ScannerResponse scannerResponse = await scannerController!.startAutoScan();
The Status of the Scanner can be controlled by setting the ScannerStatus of the Controller:
ScannerStatus scannerStatus = ScannerStatus.scanning;
You can check the /example for a more complete example, more details and further information.
Docs
About Author
Resam Taghipour
Packages and Dependencies
License
This project is licensed under the 'BSD-3-Clause' License - see the LICENSE for details.
Libraries
- web_document_scanner
- Extensions Boiler Plate