Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -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+2/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/mobile_scanner-7.0.1/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.28/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"image_picker_android","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_android-0.8.12+23/","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"],"dev_dependency":false},{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/mobile_scanner-7.0.1/","native_build":true,"dependencies":[],"dev_dependency":false}],"macos":[{"name":"file_selector_macos","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/file_selector_macos-0.9.4+3/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"image_picker_macos","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_macos-0.2.1+2/","native_build":false,"dependencies":["file_selector_macos"],"dev_dependency":false},{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/mobile_scanner-7.0.1/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"linux":[{"name":"file_selector_linux","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/file_selector_linux-0.9.3+2/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"image_picker_linux","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_linux-0.2.1+2/","native_build":false,"dependencies":["file_selector_linux"],"dev_dependency":false}],"windows":[{"name":"file_selector_windows","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/file_selector_windows-0.9.3+4/","native_build":true,"dependencies":[],"dev_dependency":false},{"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"],"dev_dependency":false}],"web":[{"name":"image_picker_for_web","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_for_web-3.0.6/","dependencies":[],"dev_dependency":false},{"name":"mobile_scanner","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/mobile_scanner-7.0.1/","dependencies":[],"dev_dependency":false}]},"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":"2025-07-06 14:07:45.052206","version":"3.32.5","swift_package_manager_enabled":{"ios":false,"macos":false}}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"image_picker_ios","path":"/Users/redgebarkley/.pub-cache/hosted/pub.dev/image_picker_ios-0.8.12+2/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"mobile_scanner","path":"/Users/redgebarkley/.pub-cache/hosted/pub.dev/mobile_scanner-7.0.1/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"/Users/redgebarkley/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.28/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"image_picker_android","path":"/Users/redgebarkley/.pub-cache/hosted/pub.dev/image_picker_android-0.8.12+23/","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"],"dev_dependency":false},{"name":"mobile_scanner","path":"/Users/redgebarkley/.pub-cache/hosted/pub.dev/mobile_scanner-7.0.1/","native_build":true,"dependencies":[],"dev_dependency":false}],"macos":[{"name":"file_selector_macos","path":"/Users/redgebarkley/.pub-cache/hosted/pub.dev/file_selector_macos-0.9.4+3/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"image_picker_macos","path":"/Users/redgebarkley/.pub-cache/hosted/pub.dev/image_picker_macos-0.2.1+2/","native_build":false,"dependencies":["file_selector_macos"],"dev_dependency":false},{"name":"mobile_scanner","path":"/Users/redgebarkley/.pub-cache/hosted/pub.dev/mobile_scanner-7.0.1/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"linux":[{"name":"file_selector_linux","path":"/Users/redgebarkley/.pub-cache/hosted/pub.dev/file_selector_linux-0.9.3+2/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"image_picker_linux","path":"/Users/redgebarkley/.pub-cache/hosted/pub.dev/image_picker_linux-0.2.1+2/","native_build":false,"dependencies":["file_selector_linux"],"dev_dependency":false}],"windows":[{"name":"file_selector_windows","path":"/Users/redgebarkley/.pub-cache/hosted/pub.dev/file_selector_windows-0.9.3+4/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"image_picker_windows","path":"/Users/redgebarkley/.pub-cache/hosted/pub.dev/image_picker_windows-0.2.1+1/","native_build":false,"dependencies":["file_selector_windows"],"dev_dependency":false}],"web":[{"name":"image_picker_for_web","path":"/Users/redgebarkley/.pub-cache/hosted/pub.dev/image_picker_for_web-3.0.6/","dependencies":[],"dev_dependency":false},{"name":"mobile_scanner","path":"/Users/redgebarkley/.pub-cache/hosted/pub.dev/mobile_scanner-7.0.1/","dependencies":[],"dev_dependency":false}]},"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":"2025-07-10 09:20:42.012407","version":"3.32.5","swift_package_manager_enabled":{"ios":false,"macos":false}}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ migrate_working_dir/
.packages
build/
.vscode
.vsCode
.vsCode
.flutter-plugins-dependencies
21 changes: 19 additions & 2 deletions lib/src/ai_barcode_scanner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ class AiBarcodeScanner extends StatefulWidget {
/// Configuration for the scanner overlay (lines, borders, colors).
final ScannerOverlayConfig overlayConfig;

/// Custom icon for the gallery button
final IconData galleryIcon;

/// Custom icon for the camera switch button
final IconData cameraSwitchIcon;

/// Custom icon for the flashlight when on
final IconData flashOnIcon;

/// Custom icon for the flashlight when off
final IconData flashOffIcon;

const AiBarcodeScanner({
super.key,
this.fit = BoxFit.cover,
Expand All @@ -128,6 +140,10 @@ class AiBarcodeScanner extends StatefulWidget {
this.setPortraitOrientation = true,
this.overlayConfig = const ScannerOverlayConfig(),
this.galleryButtonText = 'Upload from gallery',
this.galleryIcon = CupertinoIcons.photo,
this.cameraSwitchIcon = CupertinoIcons.arrow_2_circlepath,
this.flashOnIcon = CupertinoIcons.bolt_fill,
this.flashOffIcon = CupertinoIcons.bolt,
});

@override
Expand Down Expand Up @@ -225,7 +241,7 @@ class _AiBarcodeScannerState extends State<AiBarcodeScanner> {
backgroundColor: CupertinoColors.systemGrey6,
foregroundColor: CupertinoColors.darkBackgroundGray,
),
icon: const Icon(CupertinoIcons.arrow_2_circlepath),
icon: Icon(widget.cameraSwitchIcon),
onPressed: () => _controller.switchCamera(),
),
IconButton.filled(
Expand All @@ -235,7 +251,7 @@ class _AiBarcodeScannerState extends State<AiBarcodeScanner> {
: CupertinoColors.systemGrey6,
foregroundColor: CupertinoColors.darkBackgroundGray,
),
icon: const Icon(CupertinoIcons.bolt),
icon: Icon(isTorchOn ? widget.flashOnIcon : widget.flashOffIcon),
onPressed: () {
_controller.toggleTorch();
setState(() {});
Expand Down Expand Up @@ -335,6 +351,7 @@ class _AiBarcodeScannerState extends State<AiBarcodeScanner> {
controller: _controller,
isSuccess: _isSuccess,
text: widget.galleryButtonText,
icon: widget.galleryIcon,
),
const SizedBox(width: 4),
...actionIcons,
Expand Down
7 changes: 5 additions & 2 deletions lib/src/gallery_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class GalleryButton extends StatelessWidget {
final ValueNotifier<bool?> isSuccess;
final GalleryButtonType buttonType;
final String text;
final IconData? icon;

const GalleryButton({
super.key,
Expand All @@ -29,6 +30,7 @@ class GalleryButton extends StatelessWidget {
required this.isSuccess,
this.buttonType = GalleryButtonType.filled,
this.text = 'Upload from gallery',
this.icon,
});

const GalleryButton.icon({
Expand All @@ -39,6 +41,7 @@ class GalleryButton extends StatelessWidget {
required this.controller,
required this.isSuccess,
this.text = 'Upload from gallery',
this.icon = CupertinoIcons.photo,
}) : buttonType = GalleryButtonType.icon;

/// REFACTORED: The logic for picking and analyzing the image is now cleaner.
Expand Down Expand Up @@ -81,14 +84,14 @@ class GalleryButton extends StatelessWidget {
backgroundColor: CupertinoColors.systemGrey6,
foregroundColor: CupertinoColors.darkBackgroundGray,
),
icon: const Icon(CupertinoIcons.photo),
icon: Icon(icon),
onPressed: _pickAndAnalyzeImage,
);
case GalleryButtonType.filled:
return FilledButton.icon(
onPressed: _pickAndAnalyzeImage,
label: Text(text),
icon: const Icon(CupertinoIcons.photo),
icon: Icon(icon),
style: FilledButton.styleFrom(
backgroundColor: CupertinoColors.systemGrey6,
foregroundColor: CupertinoColors.darkBackgroundGray,
Expand Down
Loading