presentSheet<T> static method
Future<void>
presentSheet<T>({
- String title = "Popup",
- bool isFullScreen = true,
- bool useRootContext = false,
- Color? contentColor,
- EdgeInsets? contentPadding,
- dynamic onChanged(
- T result
- required BuildContext context,
- required Builder builder,
Implementation
static Future<void> presentSheet<T>({
String title = "Popup",
bool isFullScreen = true,
bool useRootContext = false,
Color? contentColor,
EdgeInsets? contentPadding,
Function(T result)? onChanged,
required BuildContext context,
required Builder builder,
}) async {
final result = await showModalBottomSheet(
isScrollControlled: true,
enableDrag: true,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
backgroundColor: Colors.white,
context: context,
builder: (context) => ConstrainedBox(
constraints: BoxConstraints(maxHeight: MediaQuery.sizeOf(context).height * 0.85),
child: Padding(
padding: MediaQuery.viewInsetsOf(context),
child: IntrinsicHeight(
child: Column(
children: [
AppBar(
title: Padding(
padding: const EdgeInsets.all(0),
child: Text(
title,
style: const TextStyle(fontSize: 17, fontWeight: FontWeight.w600),
),
),
automaticallyImplyLeading: false,
actions: [
IconButton(
onPressed: () {
Navigator.of(context).pop();
},
icon: const Icon(Icons.close))
],
),
ConstrainedBox(
constraints: BoxConstraints(
maxHeight:
MediaQuery.sizeOf(context).height * 0.85 - 64 - MediaQuery.viewInsetsOf(context).bottom),
child: SizedBox(
child: SingleChildScrollView(
child: Padding(
padding: contentPadding ?? EdgeInsets.zero,
child: Column(
children: [
useRootContext ? builder.build(context) : builder,
],
),
),
),
),
),
],
),
),
),
),
);
if (result != null && onChanged != null) {
onChanged(result);
}
}