Skip to content

Commit f006ed8

Browse files
authored
Merge branch 'master' into show_gallery_button
2 parents ca54ca1 + 85f6b5a commit f006ed8

File tree

10 files changed

+350
-386
lines changed

10 files changed

+350
-386
lines changed

.flutter-plugins

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# This is a generated file; do not edit or check into version control.
22
file_selector_linux=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/file_selector_linux-0.9.2+1/
3-
file_selector_macos=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/file_selector_macos-0.9.4/
4-
file_selector_windows=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/file_selector_windows-0.9.3+1/
5-
flutter_plugin_android_lifecycle=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.19/
6-
image_picker=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker-1.1.1/
7-
image_picker_android=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_android-0.8.12+1/
8-
image_picker_for_web=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_for_web-3.0.4/
9-
image_picker_ios=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_ios-0.8.11+2/
3+
file_selector_macos=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/file_selector_macos-0.9.4+1/
4+
file_selector_windows=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/file_selector_windows-0.9.3+2/
5+
flutter_plugin_android_lifecycle=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.22/
6+
image_picker=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker-1.1.2/
7+
image_picker_android=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_android-0.8.12+13/
8+
image_picker_for_web=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_for_web-3.0.5/
9+
image_picker_ios=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_ios-0.8.12/
1010
image_picker_linux=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_linux-0.2.1+1/
1111
image_picker_macos=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_macos-0.2.1+1/
1212
image_picker_windows=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_windows-0.2.1+1/
13-
mobile_scanner=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/mobile_scanner-5.1.1/
13+
mobile_scanner=/Users/arvindsangwan/.pub-cache/hosted/pub.dev/mobile_scanner-6.0.1/

.flutter-plugins-dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"image_picker_ios","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_ios-0.8.11+2/","native_build":true,"dependencies":[]},{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/mobile_scanner-5.1.1/","native_build":true,"dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.19/","native_build":true,"dependencies":[]},{"name":"image_picker_android","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_android-0.8.12+1/","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/mobile_scanner-5.1.1/","native_build":true,"dependencies":[]}],"macos":[{"name":"file_selector_macos","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/file_selector_macos-0.9.4/","native_build":true,"dependencies":[]},{"name":"image_picker_macos","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_macos-0.2.1+1/","native_build":false,"dependencies":["file_selector_macos"]},{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/mobile_scanner-5.1.1/","native_build":true,"dependencies":[]}],"linux":[{"name":"file_selector_linux","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/file_selector_linux-0.9.2+1/","native_build":true,"dependencies":[]},{"name":"image_picker_linux","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_linux-0.2.1+1/","native_build":false,"dependencies":["file_selector_linux"]}],"windows":[{"name":"file_selector_windows","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/file_selector_windows-0.9.3+1/","native_build":true,"dependencies":[]},{"name":"image_picker_windows","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_windows-0.2.1+1/","native_build":false,"dependencies":["file_selector_windows"]}],"web":[{"name":"image_picker_for_web","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_for_web-3.0.4/","dependencies":[]},{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/mobile_scanner-5.1.1/","dependencies":[]}]},"dependencyGraph":[{"name":"file_selector_linux","dependencies":[]},{"name":"file_selector_macos","dependencies":[]},{"name":"file_selector_windows","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"image_picker","dependencies":["image_picker_android","image_picker_for_web","image_picker_ios","image_picker_linux","image_picker_macos","image_picker_windows"]},{"name":"image_picker_android","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"image_picker_ios","dependencies":[]},{"name":"image_picker_linux","dependencies":["file_selector_linux"]},{"name":"image_picker_macos","dependencies":["file_selector_macos"]},{"name":"image_picker_windows","dependencies":["file_selector_windows"]},{"name":"mobile_scanner","dependencies":[]}],"date_created":"2024-05-25 23:09:40.081612","version":"3.22.1"}
1+
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"image_picker_ios","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_ios-0.8.12/","native_build":true,"dependencies":[]},{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/mobile_scanner-6.0.1/","native_build":true,"dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.22/","native_build":true,"dependencies":[]},{"name":"image_picker_android","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_android-0.8.12+13/","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/mobile_scanner-6.0.1/","native_build":true,"dependencies":[]}],"macos":[{"name":"file_selector_macos","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/file_selector_macos-0.9.4+1/","native_build":true,"dependencies":[]},{"name":"image_picker_macos","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_macos-0.2.1+1/","native_build":false,"dependencies":["file_selector_macos"]},{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/mobile_scanner-6.0.1/","native_build":true,"dependencies":[]}],"linux":[{"name":"file_selector_linux","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/file_selector_linux-0.9.2+1/","native_build":true,"dependencies":[]},{"name":"image_picker_linux","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_linux-0.2.1+1/","native_build":false,"dependencies":["file_selector_linux"]}],"windows":[{"name":"file_selector_windows","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/file_selector_windows-0.9.3+2/","native_build":true,"dependencies":[]},{"name":"image_picker_windows","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_windows-0.2.1+1/","native_build":false,"dependencies":["file_selector_windows"]}],"web":[{"name":"image_picker_for_web","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_for_web-3.0.5/","dependencies":[]},{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/mobile_scanner-6.0.1/","dependencies":[]}]},"dependencyGraph":[{"name":"file_selector_linux","dependencies":[]},{"name":"file_selector_macos","dependencies":[]},{"name":"file_selector_windows","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"image_picker","dependencies":["image_picker_android","image_picker_for_web","image_picker_ios","image_picker_linux","image_picker_macos","image_picker_windows"]},{"name":"image_picker_android","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"image_picker_ios","dependencies":[]},{"name":"image_picker_linux","dependencies":["file_selector_linux"]},{"name":"image_picker_macos","dependencies":["file_selector_macos"]},{"name":"image_picker_windows","dependencies":["file_selector_windows"]},{"name":"mobile_scanner","dependencies":[]}],"date_created":"2024-10-11 14:01:48.222361","version":"3.24.3","swift_package_manager_enabled":false}

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,4 @@ migrate_working_dir/
2929
.packages
3030
build/
3131
.vscode
32-
.vsCode
33-
34-
.flutter-plugins
35-
.flutter-plugins-dependencies
32+
.vsCode

CHANGELOG.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,55 @@
1+
## 6.0.1
2+
3+
**BREAKING CHANGES BY [MOBILE_SCANNER](https://pub.dev/packages/mobile_scanner):**
4+
5+
```
6+
- [iOS] iOS 15.5.0 is now the minimum supported iOS version.
7+
- [iOS] Updates MLKit to version 7.0.0.
8+
- [iOS] Updates the minimum supported XCode version to 15.3.0.
9+
10+
Improvements:
11+
12+
- [MacOS] Added the corners and size information to barcode results.
13+
- [MacOS] Added support for `analyzeImage`.
14+
- [MacOS] Added a Privacy Manifest.
15+
- [web] Added the size information to barcode results.
16+
- [web] Added the video output size information to barcode capture.
17+
- Added support for barcode formats to image analysis.
18+
- Updated the scanner to report any scanning errors that were encountered during processing.
19+
- Introduced a new getter `hasCameraPermission` for the `MobileScannerState`.
20+
- Fixed a bug in the lifecycle handling sample. Now instead of checking `isInitialized`,
21+
the sample recommends using `hasCameraPermission`, which also guards against camera permission errors.
22+
- Updated the behavior of `returnImage` to only determine if the camera output bytes should be sent.
23+
- Updated the behavior of `BarcodeCapture.size` to always be provided when available, regardless of `returnImage`.
24+
- [iOS] Excluded the `armv7` architecture, which is unsupported by MLKit 7.0.0.
25+
- Added a new `onDetectError` error handler to the `MobileScanner` widget, for use with `onDetect`.
26+
27+
Bugs fixed:
28+
29+
- Fixed a bug that would cause the scanner to emit an error when it was already started. Now it ignores any calls to start while it is starting.
30+
- [MacOS] Fixed a bug that prevented the `anaylzeImage()` sample from working properly.
31+
- Fixed a bug that would cause onDetect to not handle errors.
32+
```
33+
34+
## 6.0.0
35+
36+
- Dependency updates
37+
- mobile_scanner: ^6.0.1
38+
- setPortraitOrientation bool added. Now you can set the orientation.
39+
40+
## 5.2.2
41+
42+
- dependency updates
43+
44+
## 5.2.1
45+
46+
- dependency updates
47+
48+
## 5.1.1+1
49+
50+
- Readme updated
51+
- gallery button hide option added
52+
153
## 5.1.1
254

355
**BREAKING CHANGES:**

README.md

Lines changed: 72 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
</tr>
1717
</table>
1818

19+
## Platform Support
20+
21+
| Android | iOS | macOS | Web | Linux | Windows |
22+
| ------- | --- | ----- | --- | ----- | ------- |
23+
||||| :x: | :x: |
24+
1925
## Features Supported
2026

2127
See the example app for detailed implementation information.
@@ -27,12 +33,6 @@ See the example app for detailed implementation information.
2733
| scanWindow | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: |
2834
| barcodeOverlay | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: |
2935

30-
## Platform Support
31-
32-
| Android | iOS | macOS | Web | Linux | Windows |
33-
| ------- | --- | ----- | --- | ----- | ------- |
34-
||||| :x: | :x: |
35-
3636
## Platform specific setup
3737

3838
### Android
@@ -75,8 +75,8 @@ Ensure that you granted camera permission in XCode -> Signing & Capabilities:
7575

7676
## Web
7777

78-
As of version 5.0.0 adding the library to the `index.html` is no longer required,
79-
as the library is automatically loaded on first use.
78+
As of version 5.0.0 adding the barcode scanning library script to the `index.html` is no longer required,
79+
as the script is automatically loaded on first use.
8080

8181
### Providing a mirror for the barcode scanning library
8282

@@ -100,16 +100,13 @@ Import `package:ai_barcode_scanner/ai_barcode_scanner.dart`, and use the widget
100100

101101
If you don't provide a controller, you can't control functions like the torch(flash) or switching camera.
102102

103-
If you don't set allowDuplicates to false, you can get multiple scans in a very short time, causing things like pop() to fire lots of times.
103+
If you don't set `detectionSpeed: DetectionSpeed.noDuplicates`, you can get multiple scans in a very short time.
104104

105105
```dart
106106
import 'package:ai_barcode_scanner/ai_barcode_scanner.dart';
107107
108108
/// Simple example of using the barcode scanner.
109109
AiBarcodeScanner(
110-
onScan: (String value) {
111-
debugPrint(value);
112-
},
113110
onDetect: (BarcodeCapture barcodeCapture) {
114111
debugPrint(barcodeCapture);
115112
},
@@ -120,9 +117,6 @@ AiBarcodeScanner(
120117
controller: MobileScannerController(
121118
detectionSpeed: DetectionSpeed.noDuplicates,
122119
),
123-
onScan: (String value) {
124-
debugPrint(value);
125-
},
126120
onDetect: (BarcodeCapture barcodeCapture) {
127121
debugPrint(barcodeCapture);
128122
},
@@ -132,16 +126,40 @@ AiBarcodeScanner(
132126
/// Validator works on the raw string, not the decoded value.
133127
/// If you want to validate the scanner, use the [validate] parameter.
134128
AiBarcodeScanner(
135-
validate: (String value) {
136-
if(value.startsWith('http')) {
137-
return true;
138-
}
139-
return false;
140-
},
141-
onScan: (String value) {
142-
debugPrint(value);
143-
},
144-
),
129+
onDispose: () {
130+
/// This is called when the barcode scanner is disposed.
131+
/// You can write your own logic here.
132+
debugPrint("Barcode scanner disposed!");
133+
},
134+
controller: MobileScannerController(
135+
detectionSpeed: DetectionSpeed.noDuplicates,
136+
),
137+
onDetect: (BarcodeCapture capture) {
138+
/// The row string scanned barcode value
139+
final String? scannedValue =
140+
capture.barcodes.first.rawValue;
141+
142+
/// The `Uint8List` image is only available if `returnImage` is set to `true`.
143+
final Uint8List? image = capture.image;
144+
145+
/// row data of the barcode
146+
final Object? raw = capture.raw;
147+
148+
/// List of scanned barcodes if any
149+
final List<Barcode> barcodes = capture.barcodes;
150+
},
151+
validator: (value) {
152+
if (value.barcodes.isEmpty) {
153+
return false;
154+
}
155+
if (!(value.barcodes.first.rawValue
156+
?.contains('flutter.dev') ??
157+
false)) {
158+
return false;
159+
}
160+
return true;
161+
},
162+
),
145163
```
146164

147165
## Usage ([mobile_scanner](https://pub.dev/packages/mobile_scanner))
@@ -268,8 +286,11 @@ You can use the following properties of the Barcode object.
268286
/// Barcode controller (optional)
269287
final MobileScannerController? controller;
270288
271-
/// Show overlay or not (default: true)
272-
final bool showOverlay;
289+
/// You can use your own custom overlay builder
290+
/// to build your own overlay
291+
/// This will override the default custom overlay
292+
final Widget? Function(BuildContext, bool?, MobileScannerController)?
293+
customOverlayBuilder;
273294
274295
/// Overlay border color (default: white)
275296
final Color? borderColor;
@@ -330,7 +351,14 @@ You can use the following properties of the Barcode object.
330351
/// AppBar widget
331352
/// you can use this to add appBar to the scanner screen
332353
///
333-
final PreferredSizeWidget? appBar;
354+
final PreferredSizeWidget? Function(
355+
BuildContext context, MobileScannerController controller)? appBarBuilder;
356+
357+
/// The builder for the bottom sheet.
358+
/// This is displayed below the camera preview.
359+
final Widget? Function(
360+
BuildContext context, MobileScannerController controller)?
361+
bottomSheetBuilder;
334362
335363
/// The builder for the overlay above the camera preview.
336364
///
@@ -411,29 +439,36 @@ You can use the following properties of the Barcode object.
411439
final void Function(String?)? onImagePick;
412440
413441
/// Title for the draggable sheet (default: 'Scan any QR code')
414-
final String title;
442+
final String sheetTitle;
415443
416444
/// Child widget for the draggable sheet (default: SizedBox.shrink())
417-
final Widget child;
445+
final Widget sheetChild;
418446
419447
/// Hide drag handler of the draggable sheet (default: false)
420-
final bool hideDragHandler;
448+
final bool hideSheetDragHandler;
421449
422450
/// Hide title of the draggable sheet (default: false)
423-
final bool hideTitle;
451+
final bool hideSheetTitle;
452+
453+
/// Hide gallery button (default: false)
454+
/// This will hide the gallery button at the bottom of the screen
455+
final bool hideGalleryButton;
456+
457+
/// Hide gallery icon (default: false)
458+
/// This will hide the gallery icon in the app bar
459+
final bool hideGalleryIcon;
460+
461+
/// Extend body behind app bar (default: true)
462+
final bool extendBodyBehindAppBar;
424463
425464
/// Upload from gallery button alignment
426465
/// default: bottom center, center, 0.75
427-
final AlignmentGeometry? buttonAlignment;
466+
final AlignmentGeometry? galleryButtonAlignment;
428467
429468
/// actions for the app bar (optional)
430469
/// Camera switch and torch toggle buttons are added by default
431470
/// You can add more actions to the app bar using this parameter
432471
final List<Widget>? actions;
433-
434-
/// Optional function to be called when clicking the back button on the app bar
435-
/// If not provided, the default behavior is to pop the current route from the navigator
436-
final void Function()? onPop;
437472
````
438473

439474
### Contributing to [ai_barcode_scanner](https://pub.dev/packages/ai_barcode_scanner)

example/lib/main.dart

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import 'dart:developer';
2-
31
import 'package:ai_barcode_scanner/ai_barcode_scanner.dart';
2+
import 'package:flutter/foundation.dart';
43
import 'package:flutter/material.dart';
54

65
void main() {
@@ -45,18 +44,43 @@ class _HomePageState extends State<HomePage> {
4544
MaterialPageRoute(
4645
builder: (context) => AiBarcodeScanner(
4746
onDispose: () {
47+
/// This is called when the barcode scanner is disposed.
48+
/// You can write your own logic here.
4849
debugPrint("Barcode scanner disposed!");
4950
},
51+
hideGalleryButton: false,
5052
controller: MobileScannerController(
5153
detectionSpeed: DetectionSpeed.noDuplicates,
5254
),
53-
onDetect: (p0) => setState(() {
54-
barcode = p0.barcodes.first.rawValue.toString();
55-
log(barcode, name: 'Barcode');
56-
}),
57-
validator: (p0) =>
58-
p0.barcodes.first.rawValue?.startsWith('https://') ??
59-
false,
55+
onDetect: (BarcodeCapture capture) {
56+
/// The row string scanned barcode value
57+
final String? scannedValue =
58+
capture.barcodes.first.rawValue;
59+
debugPrint("Barcode scanned: $scannedValue");
60+
61+
/// The `Uint8List` image is only available if `returnImage` is set to `true`.
62+
final Uint8List? image = capture.image;
63+
debugPrint("Barcode image: $image");
64+
65+
/// row data of the barcode
66+
final Object? raw = capture.raw;
67+
debugPrint("Barcode raw: $raw");
68+
69+
/// List of scanned barcodes if any
70+
final List<Barcode> barcodes = capture.barcodes;
71+
debugPrint("Barcode list: $barcodes");
72+
},
73+
validator: (value) {
74+
if (value.barcodes.isEmpty) {
75+
return false;
76+
}
77+
if (!(value.barcodes.first.rawValue
78+
?.contains('flutter.dev') ??
79+
false)) {
80+
return false;
81+
}
82+
return true;
83+
},
6084
),
6185
),
6286
);

0 commit comments

Comments
 (0)