getBottomSheetLayoutForCameraGallery method
Widget
getBottomSheetLayoutForCameraGallery({
- String title = "Choose option",
- String camTitle = "Camera",
- String galleryTitle = "Gallery",
- String cancelTitle = "Cancel",
- String? titleFontFamily,
- String? camTitleFontFamily,
- String? galleryTitleFontFamily,
- String? cancelTitleFontFamily,
- double? titleFontSize,
- double? camTitleFontSize,
- double? galleryTitleFontSize,
- double? cancelTitleFontSize,
- double titlePadding = 16,
- double? cancelHorizontalPadding,
- double? cancelVerticalPadding,
- IconData? camIcon,
- IconData? galleryIcon,
- bool isTitleCenter = true,
- bool isGalleryTitleCenter = true,
- bool isCamTitleCenter = true,
- Color titleColor = Colors.black,
- Color camTitleColor = Colors.black,
- Color galleryTitleColor = Colors.black,
- Color cancelTitleColor = Colors.black,
- Color galleryColor = Colors.black,
- Color camColor = Colors.black,
Creates a bottom sheet layout for camera/gallery selection.
Displays a modal bottom sheet with options to select camera or gallery, along with a cancel button. The sheet automatically closes when an option is selected.
Parameters:
title: Header text for the bottom sheet (defaults to "Choose option").camTitle: Label for camera option (defaults to "Camera").galleryTitle: Label for gallery option (defaults to "Gallery").cancelTitle: Label for cancel button (defaults to "Cancel").titleFontFamily: Font family for title. Defaults toUtils.appConstants.boldFontFamily.camTitleFontFamily: Font family for camera label. Defaults toUtils.appConstants.regularFontFamily.galleryTitleFontFamily: Font family for gallery label. Defaults toUtils.appConstants.regularFontFamily.cancelTitleFontFamily: Font family for cancel button. Defaults toUtils.appConstants.boldFontFamily.titleFontSize: Font size for title. Defaults toUtils.appConstants.textHeaderFontSize.camTitleFontSize: Font size for camera label. Defaults toUtils.appConstants.normalFontSize.galleryTitleFontSize: Font size for gallery label. Defaults toUtils.appConstants.normalFontSize.cancelTitleFontSize: Font size for cancel button. Defaults toUtils.appConstants.normalFontSize.titlePadding: Padding around the title (defaults to 16).cancelHorizontalPadding: Horizontal padding for cancel button.cancelVerticalPadding: Vertical padding for cancel button.camIcon: Icon for camera option (defaults to Icons.camera_alt).galleryIcon: Icon for gallery option (defaults to Icons.photo_library).isTitleCenter: Whether to center the title (defaults to true).isGalleryTitleCenter: Whether to center gallery label (defaults to true).isCamTitleCenter: Whether to center camera label (defaults to true).titleColor: Color for title text (defaults to black).camTitleColor: Color for camera label (defaults to black).galleryTitleColor: Color for gallery label (defaults to black).cancelTitleColor: Color for cancel button text (defaults to black).galleryColor: Color for gallery icon (defaults to black).camColor: Color for camera icon (defaults to black).
Returns a Padding widget containing the bottom sheet layout.
Note: This method only creates the UI. Actual image picking logic should be implemented in the onTap callbacks.
Example:
GlobalBottomSheet.show(
getBottomSheetLayoutForCameraGallery(
title: 'Select Image Source',
camColor: Colors.blue,
galleryColor: Colors.green,
)
);
Implementation
Widget getBottomSheetLayoutForCameraGallery(
{String title = "Choose option",
String camTitle = "Camera",
String galleryTitle = "Gallery",
String cancelTitle = "Cancel",
String? titleFontFamily,
String? camTitleFontFamily,
String? galleryTitleFontFamily,
String? cancelTitleFontFamily,
double? titleFontSize,
double? camTitleFontSize,
double? galleryTitleFontSize,
double? cancelTitleFontSize,
double titlePadding = 16,
double? cancelHorizontalPadding,
double? cancelVerticalPadding,
IconData? camIcon,
IconData? galleryIcon,
bool isTitleCenter = true,
bool isGalleryTitleCenter = true,
bool isCamTitleCenter = true,
Color titleColor = Colors.black,
Color camTitleColor = Colors.black,
Color galleryTitleColor = Colors.black,
Color cancelTitleColor = Colors.black,
Color galleryColor = Colors.black,
Color camColor = Colors.black}) {
return Padding(
padding: EdgeInsets.all(Utils.appConstants.boxPadding),
child: Container(
width: Get.width,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: Utils.appConstants.bottomSheetContainerBorderRadius,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Header
Padding(
padding: EdgeInsets.all(titlePadding),
child: Utils.commonWidgets.setText(
title,
titleFontFamily ?? Utils.appConstants.boldFontFamily,
titleColor,
titleFontSize ?? Utils.appConstants.textHeaderFontSize,
isCenter: isTitleCenter),
),
const Divider(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
child: InkWell(
onTap: () async {
Get.back(); // Close the bottom sheet
// Pick image from camera
},
child: Column(
children: [
Icon(
camIcon ?? Icons.camera_alt,
color: camColor,
),
Utils.commonWidgets.setText(
camTitle,
camTitleFontFamily ??
Utils.appConstants.regularFontFamily,
camTitleColor,
camTitleFontSize ??
Utils.appConstants.normalFontSize,
isCenter: isCamTitleCenter)
],
),
),
),
Expanded(
child: InkWell(
onTap: () async {
Get.back(); // Close the bottom sheet
// Pick image from camera
},
child: Column(
children: [
Icon(
galleryIcon ?? Icons.photo_library,
color: galleryColor,
),
Utils.commonWidgets.setText(
galleryTitle,
galleryTitleFontFamily ??
Utils.appConstants.regularFontFamily,
galleryTitleColor,
galleryTitleFontSize ??
Utils.appConstants.normalFontSize,
isCenter: isGalleryTitleCenter)
],
),
),
),
],
),
// Divider line for better separation
const Divider(),
// Another divider
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
InkWell(
onTap: () async {
Get.back(); // Close the bottom sheet
// Pick image from gallery
},
child: Utils.commonWidgets.setText(
cancelTitle,
cancelTitleFontFamily ??
Utils.appConstants.boldFontFamily,
cancelTitleColor,
cancelTitleFontSize ??
Utils.appConstants.normalFontSize)),
],
),
),
],
)),
);
}