Skip to content

Commit 676ea23

Browse files
committed
chore: Update documentation and improve scanner functionality
- Added comprehensive documentation for supported barcode formats, including PDF417 - Enhanced README with examples and troubleshooting sections - Implemented Windows platform support documentation and runtime checks - Improved scanning accuracy guidelines and best practices - Fixed RenderFlex overflow in DraggableSheet widget - Updated dependencies and example configurations - Removed deprecated DraggableSheet component
1 parent 1a56825 commit 676ea23

File tree

17 files changed

+757
-576
lines changed

17 files changed

+757
-576
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,26 @@
55
- Added comprehensive documentation for supported barcode formats including PDF417
66
- Updated example to demonstrate PDF417 format configuration
77
- Enhanced README with format configuration examples
8+
- Added comprehensive documentation for supported barcode formats including PDF417
9+
- Updated example to demonstrate PDF417 format configuration
10+
- Enhanced README with format configuration examples
11+
- Added Windows platform support documentation and runtime checks
12+
- Added scanning accuracy and best practices documentation
13+
- Added troubleshooting sections for common issues:
14+
- iOS CocoaPods dependency conflicts
15+
- Scanner crashes and black screen issues
16+
- Web mobile compatibility limitations
17+
- Distance scanning accuracy limitations
18+
- Updated example to show proper navigation patterns for auto-closing scanner
19+
- Added orientation handling improvements with `restoreOrientationsOnClose` parameter
20+
- Fixed RenderFlex overflow in DraggableSheet widget
21+
22+
**Documentation:**
23+
24+
- Added comprehensive troubleshooting guide
25+
- Added platform support limitations documentation
26+
- Enhanced usage examples with best practices
27+
- Added known limitations section for dependency-related issues
828

929
## 6.0.1
1030

README.md

Lines changed: 92 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
| ------- | --- | ----- | --- | ----- | ------- |
2323
||||| :x: | :x: |
2424

25+
> **Note:** Windows is **not supported** because the underlying [mobile_scanner](https://pub.dev/packages/mobile_scanner) package does not support Windows. If you need Windows support, please follow the mobile_scanner repository for updates.
26+
2527
## Features Supported
2628

2729
See the example app for detailed implementation information.
@@ -67,6 +69,38 @@ Example,
6769
<string>This app needs photos access to get QR code from photo library</string>
6870
```
6971

72+
#### Troubleshooting iOS CocoaPods Issues
73+
74+
If you encounter CocoaPods dependency conflicts (especially with Firebase), try these steps:
75+
76+
1. **Update CocoaPods specs:**
77+
78+
```bash
79+
pod repo update
80+
```
81+
82+
2. **If that doesn't work, clean and reinstall:**
83+
84+
```bash
85+
# Delete pod files
86+
rm -rf ios/Pods ios/Podfile.lock
87+
88+
# Clean Flutter
89+
flutter clean
90+
flutter pub get
91+
92+
# Update iOS platform version in Podfile
93+
# Change platform :ios, '11.0' to platform :ios, '14.0'
94+
95+
# Reinstall pods
96+
cd ios
97+
pod install
98+
cd ..
99+
flutter build ios
100+
```
101+
102+
This is a known issue with the underlying mobile_scanner package and its dependencies.
103+
70104
### macOS
71105

72106
Ensure that you granted camera permission in XCode -> Signing & Capabilities:
@@ -78,6 +112,8 @@ Ensure that you granted camera permission in XCode -> Signing & Capabilities:
78112
As of version 5.0.0 adding the barcode scanning library script to the `index.html` is no longer required,
79113
as the script is automatically loaded on first use.
80114

115+
> **Note:** Web support may have compatibility issues on mobile devices (smartphones). For optimal mobile experience, consider using native Android/iOS apps instead of web apps.
116+
81117
### Providing a mirror for the barcode scanning library
82118

83119
If a different mirror is needed to load the barcode scanning library,
@@ -134,64 +170,57 @@ controller: MobileScannerController(
134170
),
135171
```
136172

173+
## Scanning Accuracy & Best Practices
174+
175+
### Distance Scanning
176+
177+
The barcode scanner may have reduced accuracy when scanning from a distance. For optimal results:
178+
179+
- **Keep the barcode within 10-30 cm** of the camera
180+
- **Ensure good lighting** conditions
181+
- **Hold the device steady** while scanning
182+
- **Clean the camera lens** if scanning is unclear
183+
184+
### Known Limitations
185+
186+
- **Distance accuracy**: Scanning from far distances may result in incorrect readings
187+
- **This is a limitation of the underlying [mobile_scanner](https://pub.dev/packages/mobile_scanner) package and MLKit**
188+
- For critical applications, always verify scanned values and implement validation
189+
190+
### Troubleshooting
191+
192+
If you're getting incorrect scans:
193+
194+
1. Move closer to the barcode
195+
2. Ensure the barcode is well-lit and not damaged
196+
3. Try different angles
197+
4. Clean the camera lens
198+
5. Check if the barcode format is supported
199+
200+
### Scanner Crashes
201+
202+
If the scanner crashes when opening or closing:
203+
204+
1. **Ensure proper navigation**: Use `Navigator.of(context).pop()` in `onDetect` to close the scanner
205+
2. **Controller lifecycle**: The controller is automatically managed by the widget
206+
3. **Check permissions**: Ensure camera permissions are granted
207+
4. **Platform-specific issues**: Some crashes may be related to the underlying mobile_scanner package
208+
209+
**Black Screen Issues:**
210+
211+
- Use `canPop: true` in your navigation setup
212+
- Avoid calling `Navigator.of(context).pop()` manually in `if (context.mounted){}` blocks
213+
- Let the widget handle its own navigation lifecycle
214+
215+
Example of proper navigation:
216+
137217
```dart
138-
import 'package:ai_barcode_scanner/ai_barcode_scanner.dart';
139-
140-
/// Simple example of using the barcode scanner.
141-
AiBarcodeScanner(
142-
onDetect: (BarcodeCapture barcodeCapture) {
143-
debugPrint(barcodeCapture);
144-
},
145-
),
146-
147-
/// Example of using the barcode scanner with a controller.
148-
AiBarcodeScanner(
149-
controller: MobileScannerController(
150-
detectionSpeed: DetectionSpeed.noDuplicates,
151-
),
152-
onDetect: (BarcodeCapture barcodeCapture) {
153-
debugPrint(barcodeCapture);
154-
},
155-
),
156-
157-
/// Example of using the barcode scanner with validation.
158-
/// Validator works on the raw string, not the decoded value.
159-
/// If you want to validate the scanner, use the [validate] parameter.
160-
AiBarcodeScanner(
161-
onDispose: () {
162-
/// This is called when the barcode scanner is disposed.
163-
/// You can write your own logic here.
164-
debugPrint("Barcode scanner disposed!");
165-
},
166-
controller: MobileScannerController(
167-
detectionSpeed: DetectionSpeed.noDuplicates,
168-
),
169-
onDetect: (BarcodeCapture capture) {
170-
/// The row string scanned barcode value
171-
final String? scannedValue =
172-
capture.barcodes.first.rawValue;
173-
174-
/// The `Uint8List` image is only available if `returnImage` is set to `true`.
175-
final Uint8List? image = capture.image;
176-
177-
/// row data of the barcode
178-
final Object? raw = capture.raw;
179-
180-
/// List of scanned barcodes if any
181-
final List<Barcode> barcodes = capture.barcodes;
182-
},
183-
validator: (value) {
184-
if (value.barcodes.isEmpty) {
185-
return false;
186-
}
187-
if (!(value.barcodes.first.rawValue
188-
?.contains('flutter.dev') ??
189-
false)) {
190-
return false;
191-
}
192-
return true;
193-
},
194-
),
218+
onDetect: (BarcodeCapture capture) {
219+
final String? scannedValue = capture.barcodes.first.rawValue;
220+
if (scannedValue != null) {
221+
Navigator.of(context).pop(scannedValue); // Close scanner
222+
}
223+
},
195224
```
196225

197226
## Usage ([mobile_scanner](https://pub.dev/packages/mobile_scanner))
@@ -516,3 +545,9 @@ All contributions are welcome. Let's make this package better together.
516545
</a>
517546

518547
Made with [contrib.rocks](https://contrib.rocks).
548+
549+
## Windows Support
550+
551+
**Windows is not supported.**
552+
553+
This package depends on [mobile_scanner](https://pub.dev/packages/mobile_scanner), which does not support Windows. Attempts to use the scanner on Windows will result in an error. For more information, see the [mobile_scanner pub.dev page](https://pub.dev/packages/mobile_scanner).

example/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
*.swp
66
.DS_Store
77
.atom/
8+
.build/
89
.buildlog/
910
.history
1011
.svn/
12+
.swiftpm/
1113
migrate_working_dir/
1214

1315
# IntelliJ related

example/ios/Podfile.lock

Lines changed: 14 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,9 @@
11
PODS:
2-
- Firebase/Auth (10.3.0):
3-
- Firebase/CoreOnly
4-
- FirebaseAuth (~> 10.3.0)
5-
- Firebase/CoreOnly (10.3.0):
6-
- FirebaseCore (= 10.3.0)
7-
- firebase_auth (4.2.6):
8-
- Firebase/Auth (= 10.3.0)
9-
- firebase_core
10-
- Flutter
11-
- firebase_core (2.5.0):
12-
- Firebase/CoreOnly (= 10.3.0)
13-
- Flutter
14-
- FirebaseAuth (10.3.0):
15-
- FirebaseCore (~> 10.0)
16-
- GoogleUtilities/AppDelegateSwizzler (~> 7.8)
17-
- GoogleUtilities/Environment (~> 7.8)
18-
- GTMSessionFetcher/Core (< 4.0, >= 2.1)
19-
- FirebaseCore (10.3.0):
20-
- FirebaseCoreInternal (~> 10.0)
21-
- GoogleUtilities/Environment (~> 7.8)
22-
- GoogleUtilities/Logger (~> 7.8)
23-
- FirebaseCoreInternal (10.5.0):
24-
- "GoogleUtilities/NSData+zlib (~> 7.8)"
252
- Flutter (1.0.0)
263
- GoogleDataTransport (9.2.1):
274
- GoogleUtilities/Environment (~> 7.7)
285
- nanopb (< 2.30910.0, >= 2.30908.0)
296
- PromisesObjC (< 3.0, >= 1.2)
30-
- GoogleMLKit/BarcodeScanning (3.2.0):
31-
- GoogleMLKit/MLKitCore
32-
- MLKitBarcodeScanning (~> 2.2.0)
33-
- GoogleMLKit/MLKitCore (3.2.0):
34-
- MLKitCommon (~> 8.0.0)
357
- GoogleToolboxForMac/DebugUtils (2.3.2):
368
- GoogleToolboxForMac/Defines (= 2.3.2)
379
- GoogleToolboxForMac/Defines (2.3.2)
@@ -44,30 +16,18 @@ PODS:
4416
- GoogleToolboxForMac/Defines (= 2.3.2)
4517
- "GoogleToolboxForMac/NSString+URLArguments (= 2.3.2)"
4618
- "GoogleToolboxForMac/NSString+URLArguments (2.3.2)"
47-
- GoogleUtilities/AppDelegateSwizzler (7.11.0):
48-
- GoogleUtilities/Environment
49-
- GoogleUtilities/Logger
50-
- GoogleUtilities/Network
5119
- GoogleUtilities/Environment (7.11.0):
5220
- PromisesObjC (< 3.0, >= 1.2)
5321
- GoogleUtilities/Logger (7.11.0):
5422
- GoogleUtilities/Environment
55-
- GoogleUtilities/Network (7.11.0):
56-
- GoogleUtilities/Logger
57-
- "GoogleUtilities/NSData+zlib"
58-
- GoogleUtilities/Reachability
59-
- "GoogleUtilities/NSData+zlib (7.11.0)"
60-
- GoogleUtilities/Reachability (7.11.0):
61-
- GoogleUtilities/Logger
6223
- GoogleUtilities/UserDefaults (7.11.0):
6324
- GoogleUtilities/Logger
6425
- GoogleUtilitiesComponents (1.1.0):
6526
- GoogleUtilities/Logger
6627
- GTMSessionFetcher/Core (2.3.0)
28+
- image_picker_ios (0.0.1):
29+
- Flutter
6730
- MLImage (1.0.0-beta3)
68-
- MLKitBarcodeScanning (2.2.0):
69-
- MLKitCommon (~> 8.0)
70-
- MLKitVision (~> 4.2)
7131
- MLKitCommon (8.0.0):
7232
- GoogleDataTransport (~> 9.0)
7333
- GoogleToolboxForMac/Logger (~> 2.1)
@@ -84,9 +44,9 @@ PODS:
8444
- MLImage (= 1.0.0-beta3)
8545
- MLKitCommon (~> 8.0)
8646
- Protobuf (~> 3.12)
87-
- mobile_scanner (3.0.0):
47+
- mobile_scanner (7.0.0):
8848
- Flutter
89-
- GoogleMLKit/BarcodeScanning (~> 3.2.0)
49+
- FlutterMacOS
9050
- nanopb (2.30909.0):
9151
- nanopb/decode (= 2.30909.0)
9252
- nanopb/encode (= 2.30909.0)
@@ -96,68 +56,52 @@ PODS:
9656
- Protobuf (3.22.0)
9757

9858
DEPENDENCIES:
99-
- firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)
100-
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
10159
- Flutter (from `Flutter`)
60+
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
10261
- MLKitCommon (from `MLKitCommon.podspec.json`)
10362
- MLKitVision (from `MLKitVision.podspec.json`)
104-
- mobile_scanner (from `.symlinks/plugins/mobile_scanner/ios`)
63+
- mobile_scanner (from `.symlinks/plugins/mobile_scanner/darwin`)
10564

10665
SPEC REPOS:
10766
trunk:
108-
- Firebase
109-
- FirebaseAuth
110-
- FirebaseCore
111-
- FirebaseCoreInternal
11267
- GoogleDataTransport
113-
- GoogleMLKit
11468
- GoogleToolboxForMac
11569
- GoogleUtilities
11670
- GoogleUtilitiesComponents
11771
- GTMSessionFetcher
11872
- MLImage
119-
- MLKitBarcodeScanning
12073
- nanopb
12174
- PromisesObjC
12275
- Protobuf
12376

12477
EXTERNAL SOURCES:
125-
firebase_auth:
126-
:path: ".symlinks/plugins/firebase_auth/ios"
127-
firebase_core:
128-
:path: ".symlinks/plugins/firebase_core/ios"
12978
Flutter:
13079
:path: Flutter
80+
image_picker_ios:
81+
:path: ".symlinks/plugins/image_picker_ios/ios"
13182
MLKitCommon:
13283
:podspec: MLKitCommon.podspec.json
13384
MLKitVision:
13485
:podspec: MLKitVision.podspec.json
13586
mobile_scanner:
136-
:path: ".symlinks/plugins/mobile_scanner/ios"
87+
:path: ".symlinks/plugins/mobile_scanner/darwin"
13788

13889
SPEC CHECKSUMS:
139-
Firebase: f92fc551ead69c94168d36c2b26188263860acd9
140-
firebase_auth: b196f91b4f7c6d72015c3c12aaa82eb6972b2c2c
141-
firebase_core: f95c8bbe65213d406d592573ad42a12d64849cb8
142-
FirebaseAuth: 0e415d29d846c1dce2fb641e46f35e9888d9bec6
143-
FirebaseCore: 988754646ab3bd4bdcb740f1bfe26b9f6c0d5f2a
144-
FirebaseCoreInternal: e463f41bb935cd049505bf7e9a5bdd7dcea90df6
145-
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
90+
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
14691
GoogleDataTransport: ea169759df570f4e37bdee1623ec32a7e64e67c4
147-
GoogleMLKit: 0017a6a8372e1a182139b9def4d89be5d87ca5a7
14892
GoogleToolboxForMac: 8bef7c7c5cf7291c687cf5354f39f9db6399ad34
14993
GoogleUtilities: c2bdc4cf2ce786c4d2e6b3bcfd599a25ca78f06f
15094
GoogleUtilitiesComponents: 679b2c881db3b615a2777504623df6122dd20afe
15195
GTMSessionFetcher: 3a63d75eecd6aa32c2fc79f578064e1214dfdec2
96+
image_picker_ios: 7fe1ff8e34c1790d6fff70a32484959f563a928a
15297
MLImage: 489dfec109f21da8621b28d476401aaf7a0d4ff4
153-
MLKitBarcodeScanning: d92fe1911001ec36870162c5a0eb206f612b7169
15498
MLKitCommon: 8e5dbe4b12a434e790734211e1b00ed2db3c94ae
15599
MLKitVision: 7798eded05a31f1ec7be02290e146fc4a253f984
156-
mobile_scanner: 004f7ad2fe4e2b5a3e6ed0bc4b83ca9c5b5dd975
100+
mobile_scanner: 9157936403f5a0644ca3779a38ff8404c5434a93
157101
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
158102
PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef
159103
Protobuf: 5e6cbc143d02fe08585d86b0098f8b755d2caaab
160104

161-
PODFILE CHECKSUM: 03b123506681943d03219f50e0feca4c81e97db7
105+
PODFILE CHECKSUM: ae7c5d48c79591186378fc9a3403ad923b66b876
162106

163-
COCOAPODS: 1.11.3
107+
COCOAPODS: 1.16.2

0 commit comments

Comments
 (0)