showPhotoSelectorWithSource function
Implementation
Future<PhotoSelection?> showPhotoSelectorWithSource(
BuildContext context,
) async {
var style = const TextStyle(fontSize: 16, color: CommonColors.color_333333);
var select = await showBottomChoose<int>(
context: context,
actions: [
CupertinoActionSheetAction(
onPressed: () {
Navigator.pop(context, 1);
},
child: Text(
S.of(context).takePhoto,
style: style,
),
),
CupertinoActionSheetAction(
onPressed: () {
Navigator.pop(context, 2);
},
child: Text(
S.of(context).choosePhoto,
style: style,
),
),
],
showCancel: true);
if (select == 1) {
final path = await pickPhoto(context, true);
return path == null ? null : PhotoSelection(path: path, isCamera: true);
} else if (select == 2) {
final path = await showImagePicker(context);
return path == null ? null : PhotoSelection(path: path, isCamera: false);
}
return null;
}