Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
mobile_scanner
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Navaron Bracke
2024-09-10 11:08:28 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2d767fdfaef371c6d398b6c10a9e43c8062f6801
2d767fdf
1 parent
6d904181
add barcode formats to analyze image method
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
4 deletions
lib/src/method_channel/mobile_scanner_method_channel.dart
lib/src/mobile_scanner_platform_interface.dart
lib/src/web/mobile_scanner_web.dart
lib/src/method_channel/mobile_scanner_method_channel.dart
View file @
2d767fd
...
...
@@ -3,6 +3,7 @@ import 'dart:async';
import
'package:flutter/foundation.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:mobile_scanner/src/enums/barcode_format.dart'
;
import
'package:mobile_scanner/src/enums/mobile_scanner_authorization_state.dart'
;
import
'package:mobile_scanner/src/enums/mobile_scanner_error_code.dart'
;
import
'package:mobile_scanner/src/enums/torch_state.dart'
;
...
...
@@ -140,11 +141,22 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
}
@override
Future
<
BarcodeCapture
?>
analyzeImage
(
String
path
)
async
{
Future
<
BarcodeCapture
?>
analyzeImage
(
String
path
,
{
List
<
BarcodeFormat
>
formats
=
const
<
BarcodeFormat
>[],
})
async
{
final
Map
<
Object
?,
Object
?>?
result
=
await
methodChannel
.
invokeMapMethod
<
Object
?,
Object
?>(
'analyzeImage'
,
path
,
{
'filePath'
:
path
,
'formats'
:
formats
.
isEmpty
?
null
:
[
for
(
final
BarcodeFormat
format
in
formats
)
if
(
format
!=
BarcodeFormat
.
unknown
)
format
.
rawValue
,
],
},
);
return
_parseBarcode
(
result
);
...
...
lib/src/mobile_scanner_platform_interface.dart
View file @
2d767fd
import
'package:flutter/widgets.dart'
;
import
'package:mobile_scanner/src/enums/barcode_format.dart'
;
import
'package:mobile_scanner/src/enums/torch_state.dart'
;
import
'package:mobile_scanner/src/method_channel/mobile_scanner_method_channel.dart'
;
import
'package:mobile_scanner/src/mobile_scanner_view_attributes.dart'
;
...
...
@@ -46,9 +47,15 @@ abstract class MobileScannerPlatform extends PlatformInterface {
/// Analyze a local image file for barcodes.
///
/// The [path] is the path to the file on disk.
/// The [formats] specify the barcode formats that should be detected.
///
/// If [formats] is empty, all barcode formats will be detected.
///
/// Returns the barcodes that were found in the image.
Future
<
BarcodeCapture
?>
analyzeImage
(
String
path
)
{
Future
<
BarcodeCapture
?>
analyzeImage
(
String
path
,
{
List
<
BarcodeFormat
>
formats
=
const
<
BarcodeFormat
>[],
})
{
throw
UnimplementedError
(
'analyzeImage() has not been implemented.'
);
}
...
...
lib/src/web/mobile_scanner_web.dart
View file @
2d767fd
...
...
@@ -4,6 +4,7 @@ import 'dart:ui_web' as ui_web;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_web_plugins/flutter_web_plugins.dart'
;
import
'package:mobile_scanner/src/enums/barcode_format.dart'
;
import
'package:mobile_scanner/src/enums/camera_facing.dart'
;
import
'package:mobile_scanner/src/enums/mobile_scanner_error_code.dart'
;
import
'package:mobile_scanner/src/enums/torch_state.dart'
;
...
...
@@ -232,7 +233,10 @@ class MobileScannerWeb extends MobileScannerPlatform {
}
@override
Future
<
BarcodeCapture
?>
analyzeImage
(
String
path
)
{
Future
<
BarcodeCapture
?>
analyzeImage
(
String
path
,
{
List
<
BarcodeFormat
>
formats
=
const
<
BarcodeFormat
>[],
})
{
throw
UnsupportedError
(
'analyzeImage() is not supported on the web.'
);
}
...
...
Please
register
or
login
to post a comment