Skip to content

Commit 65828bc

Browse files
committed
feat : optionBuilder callback added
1 parent 904332f commit 65828bc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/src/image_source_sheet.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import 'package:image_picker/image_picker.dart';
33

44
import 'image_source_option.dart';
55

6+
typedef FutureVoidCallBack = Future<void> Function();
7+
68
class ImageSourceBottomSheet extends StatefulWidget {
79
/// Optional maximum height of image
810
final double? maxHeight;
@@ -37,6 +39,10 @@ class ImageSourceBottomSheet extends StatefulWidget {
3739
final EdgeInsets? bottomSheetPadding;
3840
final bool preventPop;
3941

42+
final Widget Function(
43+
FutureVoidCallBack cameraPicker, FutureVoidCallBack galleryPicker)?
44+
optionsBuilder;
45+
4046
const ImageSourceBottomSheet({
4147
Key? key,
4248
this.remainingImages,
@@ -51,6 +57,7 @@ class ImageSourceBottomSheet extends StatefulWidget {
5157
this.cameraLabel,
5258
this.galleryLabel,
5359
this.bottomSheetPadding,
60+
this.optionsBuilder,
5461
required this.availableImageSources,
5562
}) : super(key: key);
5663

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

98105
@override
99106
Widget build(BuildContext context) {
107+
if (widget.optionsBuilder != null) {
108+
return widget.optionsBuilder!(
109+
() => _onPickImage(ImageSource.camera),
110+
() => _onPickImage(ImageSource.gallery),
111+
);
112+
}
100113
Widget res = Container(
101114
padding: widget.bottomSheetPadding,
102115
child: Wrap(

0 commit comments

Comments
 (0)