Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add property for show gallery button or not #111

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions lib/src/ai_barcode_scanner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ class AiBarcodeScanner extends StatefulWidget {
/// You can add more actions to the app bar using this parameter
final List<Widget>? actions;

/// Show button that allows the user to pick an image from the gallery or not (default: true)
final bool showGalleryButton;

/// Optional function to be called when clicking the back button on the app bar
/// If not provided, the default behavior is to pop the current route from the navigator
final void Function()? onPop;
Expand Down Expand Up @@ -216,6 +219,7 @@ class AiBarcodeScanner extends StatefulWidget {
this.buttonAlignment,
this.actions,
this.onPop,
this.showGalleryButton = true,
});

@override
Expand Down Expand Up @@ -279,7 +283,7 @@ class _AiBarcodeScannerState extends State<AiBarcodeScanner> {
: const Icon(Icons.flashlight_on_rounded),
onPressed: () => controller.toggleTorch(),
),
if (isLandscape)
if (isLandscape && widget.showGalleryButton)
GalleryButton.icon(
onImagePick: widget.onImagePick,
onDetect: widget.onDetect,
Expand Down Expand Up @@ -344,7 +348,7 @@ class _AiBarcodeScannerState extends State<AiBarcodeScanner> {
);
},
),
if (!isLandscape)
if (!isLandscape && widget.showGalleryButton)
Align(
alignment: widget.buttonAlignment ??
Alignment.lerp(
Expand Down