flutter_web_twain
The Flutter plugin is a wrapper for Dynamsoft's Web TWAIN SDK. It allows you to build web document scanning applications with Flutter.
Getting a License Key for Dynamic Web TWAIN
Installation
-
Add
flutter_web_twain
as a dependency in your pubspec.yaml file. -
In the root of your project, download the Dynamic Web TWAIN npm package:
npm install dwt
-
Include the following line in your
index.html
file:<script src="node_modules/dwt/dist/dynamsoft.webtwain.min.js"></script>
Usage
-
Initialize the Flutter Web TWAIN SDK:
final FlutterWebTwain _flutterWebTwain = FlutterWebTwain(); WebTwainController _controller = await _flutterWebTwain.createWebTwainController(); await _controller!.init('node_modules/dwt/dist/', 'LICENSE-KEY');
-
Embed the image container into your widget tree:
Expanded( child: _controller == null ? const CircularProgressIndicator() : HtmlElementView(viewType: _controller!.webviewId), ),
-
Acquire documents from a document scanner:
await _controller!.scan( '{"IfShowUI": false, "PixelType": ${_pixelFormat!.index}}');
-
Load images from the local file system:
await _controller!.load();
-
Save single or multiple images as PDF, TIFF or JPEG:
await _controller!.download(FileFormat.PDF.index, 'filename');
Try the Example
cd example
flutter run -d chrome
Libraries
- flutter_web_twain
- flutter_web_twain_method_channel
- flutter_web_twain_platform_interface
- flutter_web_twain_web
- shims/dart_js_util
- shims/dart_ui
- This file shims dart:ui in web-only scenarios, getting rid of the need to suppress analyzer warnings.
- shims/dart_ui_fake
- shims/dart_ui_real
- utils
- web_twain_controller
- web_twain_manager