customBottomSheet function
void
customBottomSheet({})
Implementation
void customBottomSheet({
required BuildContext context,
Widget? child,
String? title,
TextStyle? titleTxtStyle,
String? supTitle,
double borderRadius = 30,
double? titleBottomPadding,
double? sheetHeightFraction, // Adjust the fraction to control the height
Color? bgColor,
bool hasPillGesture = true,
bool isScrollControlled = true,
VoidCallback? onWillPop,
}) {
showModalBottomSheet(
isScrollControlled: isScrollControlled,
context: context,
builder: (_) {
return PopScope(
onPopInvokedWithResult: (bool canPop, dynamic data) {
if (onWillPop != null) {
onWillPop(); // Trigger pop event callback if provided
}
},
child: Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom,
),
child: FractionallySizedBox(
heightFactor: sheetHeightFraction, // Set the height factor here
child: Container(
padding: const EdgeInsets.all(16.0),
decoration: BoxDecoration(
color: bgColor ?? Theme.of(context).canvasColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(borderRadius),
topRight: Radius.circular(borderRadius),
),
),
child: SingleChildScrollView(
reverse: true,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
if (hasPillGesture) const PillGesture(), // Added here
if (title != null)
Padding(
padding:
EdgeInsets.only(bottom: titleBottomPadding ?? 16.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(title ?? '',
style: titleTxtStyle ??
AppTxtStyles.kMidTitleTextStyle),
if (supTitle != null)
Text(supTitle ?? '',
style: AppTxtStyles.kSubTitleLightTextStyle),
],
),
),
Container(child: child),
],
),
),
),
),
),
);
},
);
}