Skip to content

Commit 8c2c933

Browse files
committed
feat: Add hide gallery button option to barcode scanner
1 parent ed81ffc commit 8c2c933

File tree

7 files changed

+178
-148
lines changed

7 files changed

+178
-148
lines changed

.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.12/","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.20/","native_build":true,"dependencies":[]},{"name":"image_picker_android","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_android-0.8.12+3/","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-06-27 12:00:39.264106","version":"3.22.2"}
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-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.20/","native_build":true,"dependencies":[]},{"name":"image_picker_android","path":"/Users/arvindsangwan/.pub-cache/hosted/pub.dev/image_picker_android-0.8.12+3/","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-07-01 23:13:36.687833","version":"3.22.2"}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## 5.1.1+1
22

3+
- Readme updated
4+
- gallery button hide option fixed
5+
6+
## 5.1.1+1
7+
38
- Readme updated
49
- gallery button hide option added
510

README.md

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,11 @@ You can use the following properties of the Barcode object.
286286
/// Barcode controller (optional)
287287
final MobileScannerController? controller;
288288
289-
/// Show overlay or not (default: true)
290-
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;
291294
292295
/// Overlay border color (default: white)
293296
final Color? borderColor;
@@ -348,7 +351,14 @@ You can use the following properties of the Barcode object.
348351
/// AppBar widget
349352
/// you can use this to add appBar to the scanner screen
350353
///
351-
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;
352362
353363
/// The builder for the overlay above the camera preview.
354364
///
@@ -429,29 +439,36 @@ You can use the following properties of the Barcode object.
429439
final void Function(String?)? onImagePick;
430440
431441
/// Title for the draggable sheet (default: 'Scan any QR code')
432-
final String title;
442+
final String sheetTitle;
433443
434444
/// Child widget for the draggable sheet (default: SizedBox.shrink())
435-
final Widget child;
445+
final Widget sheetChild;
436446
437447
/// Hide drag handler of the draggable sheet (default: false)
438-
final bool hideDragHandler;
448+
final bool hideSheetDragHandler;
439449
440450
/// Hide title of the draggable sheet (default: false)
441-
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;
442463
443464
/// Upload from gallery button alignment
444465
/// default: bottom center, center, 0.75
445-
final AlignmentGeometry? buttonAlignment;
466+
final AlignmentGeometry? galleryButtonAlignment;
446467
447468
/// actions for the app bar (optional)
448469
/// Camera switch and torch toggle buttons are added by default
449470
/// You can add more actions to the app bar using this parameter
450471
final List<Widget>? actions;
451-
452-
/// Optional function to be called when clicking the back button on the app bar
453-
/// If not provided, the default behavior is to pop the current route from the navigator
454-
final void Function()? onPop;
455472
````
456473

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

example/lib/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class _HomePageState extends State<HomePage> {
4848
/// You can write your own logic here.
4949
debugPrint("Barcode scanner disposed!");
5050
},
51+
hideGalleryButton: false,
5152
controller: MobileScannerController(
5253
detectionSpeed: DetectionSpeed.noDuplicates,
5354
),

0 commit comments

Comments
 (0)