m8ty_client_docscan
Package overview
Section titled “Package overview”m8ty_client_docscan solves this by sending documents to the service for code detection and returning matching codes, allowing apps to turn scans into guided digital journeys.
Document scan client can be used to take documents like PDF, JPEG, PNG etc. and to send them to the server for QR code scan. If there are codes available those will be returned to the client.
Before you start
Section titled “Before you start”Check the documentation of the m8ty_client_docscan library to get an idea about the available models and their properties.
Import all needed libraries
Section titled “Import all needed libraries” import 'package:dio/dio.dart'; import 'package:m8ty_client_docscan/m8ty_client_docscan.dart'; import 'package:m8ty_client_common/m8ty_client_common.dart'; import 'package:built_collection/built_collection.dart';Client Setup
Section titled “Client Setup”final docscanClient = M8tyClientDocscan();docscanClient.setApiKey(m8tyApiKeyAuth, "myApiKey");API Surface
Section titled “API Surface”DocumentScanApi
Section titled “DocumentScanApi”| Method | Description |
|---|---|
scanForCodes |
Scan document for codes like QR codes |
How to perform different tasks
Section titled “How to perform different tasks”Here some examples how the dart client can be used
Scan some documents by using filter
Section titled “Scan some documents by using filter” final docscanClient = M8tyClientDocscan(); docscanClient.setApiKey(m8tyApiKeyAuth, "myApiKey");
final DocumentScanApi documentScanApi = docscanClient.getDocumentScanApi();
// Create MultipartFile documents final file1 = MultipartFile.fromFile( 'path/to/your/file1.jpg', filename: 'file1.jpg', ); final file2 = MultipartFile.fromFile( 'path/to/your/file2.pdf', filename: 'file2.pdf', );
// Add the files to a BuiltList final documents = BuiltList<MultipartFile>([file1, file2]);
// Specify the types (optional) final types = BuiltList<CodeTypeModel>([ CodeTypeModel.qrcode, ]);
try { final Response<ScanCodeResponseModel> scanResponse = await documentScanApi.scanForCodes( documents: documents, types: types, filter: "^SPC[\\s\\S]*\$", ); print('Scanned codes: ${scanResponse.data}'); } on DioException catch (e) { throw Exception( 'Request failed (status: ${e.response?.statusCode}): ${e.response?.data}', ); }© m8ty GmbH 2023 · m8ty.eu
