Skip to content

Commit f3c22d0

Browse files
committed
chore: Update documentation and improve example configurations
- Updated CHANGELOG with a link to the migration guide for AiBarcodeScanner class changes. - Modified pubspec.yaml to reflect the new repository and issue tracker URLs. - Enhanced README with clearer descriptions, improved layout, and added screenshots. - Removed outdated assets and improved example app structure for better usability. - Added new features and customization options for the scanner interface.
1 parent 625106b commit f3c22d0

16 files changed

+473
-566
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
- Added platform support limitations documentation
2323
- Enhanced usage examples with best practices
2424
- Added known limitations section for dependency-related issues
25-
- Major changes in AiBarcodeScanner class with new parameters and ui improvements, read the migration guide for more details.
25+
- [Major changes in AiBarcodeScanner class with new parameters and ui improvements, read the migration guide for more details](https://github.com/itsarvinddev/barcode_scanner/blob/main/MIGRATION_GUIDE.md).
2626

2727
## 6.0.1
2828

MIGRATION_GUIDE.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# Migration Guide
2+
3+
This guide will help you migrate your `ai_barcode_scanner` implementation from the older versions to the new, refactored version. The new version introduces a much cleaner, more robust, and more customizable API.
4+
5+
The primary change is the consolidation of numerous individual styling parameters into a single, powerful configuration object: `ScannerOverlayConfig`.
6+
7+
## Key Changes
8+
9+
1. **Overlay Configuration**: Almost all direct overlay parameters (`borderColor`, `borderWidth`, `overlayColor`, `borderRadius`, `borderLength`, etc.) have been removed from the `AiBarcodeScanner` constructor. You now pass a single `ScannerOverlayConfig` object to the `overlayConfig` parameter.
10+
2. **Draggable Sheet Removed**: The built-in `DraggableSheet` has been removed in favor of the more flexible `bottomSheetBuilder`. This allows you to use any widget (including `DraggableScrollableSheet`) as a bottom sheet.
11+
3. **Gallery Button**: The `hideGalleryButton` and `hideGalleryIcon` parameters have been replaced by a single `galleryButtonType` enum (`GalleryButtonType.filled` or `GalleryButtonType.icon`). To hide the gallery button completely, don't implement the `onImagePick` callback (though this is not a direct feature).
12+
4. **Pinch-to-Zoom**: This feature is now enabled by default and does not require a parameter.
13+
5. **Transient Feedback Color**: A new parameter `colorTransitionDuration` controls how long the success/error colors are displayed.
14+
15+
---
16+
17+
## Migration Steps
18+
19+
### 1. Update Overlay Parameters
20+
21+
The biggest change is how you style the overlay.
22+
23+
**Old Code:**
24+
```dart
25+
AiBarcodeScanner(
26+
borderColor: Colors.amber,
27+
borderWidth: 8,
28+
borderRadius: 20,
29+
borderLength: 40,
30+
overlayColor: Colors.black.withOpacity(0.6),
31+
cutOutSize: 280,
32+
successColor: Colors.greenAccent,
33+
errorColor: Colors.redAccent,
34+
//...
35+
)
36+
```
37+
38+
**New Code:**
39+
40+
You now group these properties into a `ScannerOverlayConfig` object.
41+
42+
```dart
43+
import 'package:ai_barcode_scanner/ai_barcode_scanner.dart';
44+
45+
AiBarcodeScanner(
46+
overlayConfig: const ScannerOverlayConfig(
47+
borderColor: Colors.amber,
48+
// Note: borderWidth is now part of the painter and not directly configurable
49+
// from the config. It has a fixed, well-proportioned value.
50+
borderRadius: 20,
51+
cornerLength: 40,
52+
backgroundBlurColor: Colors.black54, // Replaces overlayColor
53+
successColor: Colors.greenAccent,
54+
errorColor: Colors.redAccent,
55+
56+
// New Options!
57+
scannerAnimation: ScannerAnimation.center, // or .fullWidth
58+
scannerBorder: ScannerBorder.corner, // or .full
59+
),
60+
//...
61+
)
62+
```
63+
64+
### 2. Replace `DraggableSheet` with `bottomSheetBuilder`
65+
66+
If you were using `sheetTitle` or `sheetChild`, you now need to provide your own bottom sheet widget via `bottomSheetBuilder`.
67+
68+
**Old Code:**
69+
```dart
70+
AiBarcodeScanner(
71+
sheetTitle: "My Custom Title",
72+
sheetChild: MyCustomWidget(),
73+
)
74+
```
75+
76+
**New Code:**
77+
78+
Recreate the draggable sheet (or any other widget) using `bottomSheetBuilder`.
79+
80+
```dart
81+
AiBarcodeScanner(
82+
bottomSheetBuilder: (context, controller) {
83+
return DraggableScrollableSheet(
84+
initialChildSize: 0.1,
85+
minChildSize: 0.1,
86+
maxChildSize: 0.4,
87+
builder: (context, scrollController) {
88+
return SingleChildScrollView(
89+
controller: scrollController,
90+
child: Column(
91+
children: [
92+
// Your custom drag handler, title, and child here
93+
Text("My Custom Title"),
94+
const Divider(),
95+
MyCustomWidget(),
96+
],
97+
),
98+
);
99+
},
100+
);
101+
},
102+
)
103+
```
104+
105+
### 3. Update Gallery Button Logic
106+
107+
The boolean flags `hideGalleryButton` and `hideGalleryIcon` are gone. Control the button's appearance with `galleryButtonType`.
108+
109+
**Old Code:**
110+
```dart
111+
// To show icon in AppBar
112+
AiBarcodeScanner(
113+
hideGalleryIcon: false,
114+
hideGalleryButton: true,
115+
)
116+
117+
// To show button at bottom
118+
AiBarcodeScanner(
119+
hideGalleryIcon: true,
120+
hideGalleryButton: false,
121+
)
122+
```
123+
124+
**New Code:**
125+
```dart
126+
// To show icon in AppBar
127+
AiBarcodeScanner(
128+
galleryButtonType: GalleryButtonType.icon,
129+
)
130+
131+
// To show button at bottom (this is the default)
132+
AiBarcodeScanner(
133+
galleryButtonType: GalleryButtonType.filled,
134+
)
135+
```
136+
137+
### 4. Parameter Mapping Table
138+
139+
| Old Parameter | New Parameter / How to achieve | Notes |
140+
| ---------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- |
141+
| `borderColor` | `overlayConfig.borderColor` | Moved into `ScannerOverlayConfig`. |
142+
| `borderWidth` | (Removed) | The border width is now fixed for a cleaner look. |
143+
| `borderRadius` | `overlayConfig.borderRadius` | Moved into `ScannerOverlayConfig`. |
144+
| `borderLength` | `overlayConfig.cornerLength` | Renamed and moved into `ScannerOverlayConfig`. |
145+
| `overlayColor` | `overlayConfig.backgroundBlurColor` | Moved and renamed for clarity. Now uses a blur effect. |
146+
| `cutOutWidth` | (Removed) | The scan window is now responsive by default. Use `scanWindow` for custom size. |
147+
| `cutOutHeight` | (Removed) | The scan window is now responsive by default. Use `scanWindow` for custom size. |
148+
| `cutOutSize` | (Removed) | Use the `scanWindow` parameter with a `Rect` for full control. |
149+
| `cutOutBottomOffset` | (Removed) | The scan window is now centered by default. Use `scanWindow` for custom positioning. |
150+
| `showError` | `overlayConfig.animateOnError` | Moved into `ScannerOverlayConfig`. |
151+
| `showSuccess` | `overlayConfig.animateOnSuccess` | Moved into `ScannerOverlayConfig`. |
152+
| `successColor` | `overlayConfig.successColor` | Moved into `ScannerOverlayConfig`. |
153+
| `errorColor` | `overlayConfig.errorColor` | Moved into `ScannerOverlayConfig`. |
154+
| `sheetTitle` | Use `bottomSheetBuilder` | Replaced by a more flexible builder. |
155+
| `sheetChild` | Use `bottomSheetBuilder` | Replaced by a more flexible builder. |
156+
| `hideSheetDragHandler` | Use `bottomSheetBuilder` | Your custom bottom sheet now controls its own UI. |
157+
| `hideSheetTitle` | Use `bottomSheetBuilder` | Your custom bottom sheet now controls its own UI. |
158+
| `hideGalleryButton` | Use `galleryButtonType` | Replaced by the `galleryButtonType` enum. |
159+
| `hideGalleryIcon` | Use `galleryButtonType` | Replaced by the `galleryButtonType` enum. |
160+
161+
The rest of the parameters like `onDetect`, `controller`, `validator`, and `onDispose` remain largely the same and should work as before. This refactoring has simplified the API while increasing its power and customizability.

0 commit comments

Comments
 (0)