Skip to content

Commit

Permalink
feat : optionBuilder callback added
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmeabhi12 committed Nov 17, 2022
1 parent 904332f commit 65828bc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/src/image_source_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'package:image_picker/image_picker.dart';

import 'image_source_option.dart';

typedef FutureVoidCallBack = Future<void> Function();

class ImageSourceBottomSheet extends StatefulWidget {
/// Optional maximum height of image
final double? maxHeight;
Expand Down Expand Up @@ -37,6 +39,10 @@ class ImageSourceBottomSheet extends StatefulWidget {
final EdgeInsets? bottomSheetPadding;
final bool preventPop;

final Widget Function(
FutureVoidCallBack cameraPicker, FutureVoidCallBack galleryPicker)?
optionsBuilder;

const ImageSourceBottomSheet({
Key? key,
this.remainingImages,
Expand All @@ -51,6 +57,7 @@ class ImageSourceBottomSheet extends StatefulWidget {
this.cameraLabel,
this.galleryLabel,
this.bottomSheetPadding,
this.optionsBuilder,
required this.availableImageSources,
}) : super(key: key);

Expand Down Expand Up @@ -97,6 +104,12 @@ class ImageSourceBottomSheetState extends State<ImageSourceBottomSheet> {

@override
Widget build(BuildContext context) {
if (widget.optionsBuilder != null) {
return widget.optionsBuilder!(
() => _onPickImage(ImageSource.camera),
() => _onPickImage(ImageSource.gallery),
);
}
Widget res = Container(
padding: widget.bottomSheetPadding,
child: Wrap(
Expand Down

0 comments on commit 65828bc

Please sign in to comment.