Skip to content

Commit ca54ca1

Browse files
author
aslangery
committed
add property for show gallery button or not
1 parent f07bef0 commit ca54ca1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/src/ai_barcode_scanner.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ class AiBarcodeScanner extends StatefulWidget {
178178
/// You can add more actions to the app bar using this parameter
179179
final List<Widget>? actions;
180180

181+
/// Show button that allows the user to pick an image from the gallery or not (default: true)
182+
final bool showGalleryButton;
183+
181184
/// Optional function to be called when clicking the back button on the app bar
182185
/// If not provided, the default behavior is to pop the current route from the navigator
183186
final void Function()? onPop;
@@ -216,6 +219,7 @@ class AiBarcodeScanner extends StatefulWidget {
216219
this.buttonAlignment,
217220
this.actions,
218221
this.onPop,
222+
this.showGalleryButton = true,
219223
});
220224

221225
@override
@@ -279,7 +283,7 @@ class _AiBarcodeScannerState extends State<AiBarcodeScanner> {
279283
: const Icon(Icons.flashlight_on_rounded),
280284
onPressed: () => controller.toggleTorch(),
281285
),
282-
if (isLandscape)
286+
if (isLandscape && widget.showGalleryButton)
283287
GalleryButton.icon(
284288
onImagePick: widget.onImagePick,
285289
onDetect: widget.onDetect,
@@ -344,7 +348,7 @@ class _AiBarcodeScannerState extends State<AiBarcodeScanner> {
344348
);
345349
},
346350
),
347-
if (!isLandscape)
351+
if (!isLandscape && widget.showGalleryButton)
348352
Align(
349353
alignment: widget.buttonAlignment ??
350354
Alignment.lerp(

0 commit comments

Comments
 (0)