showBottomSheet static method
void
showBottomSheet(
- BuildContext context, {
- String? title,
- required String? body,
- String? url,
- int? scale,
- required dynamic onOkPressed(),
Implementation
static void showBottomSheet(
BuildContext context, {
String? title,
required String? body,
String? url,
int? scale,
required Function() onOkPressed,
}) {
var isDarkTheme = Theme.of(context).brightness == Brightness.dark;
showModalBottomSheet(
context: context,
isDismissible: false,
// isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) {
return SingleChildScrollView(
child: Container(
padding: EdgeInsets.only(
top: padding,
bottom: padding * 2,
left: padding,
right: padding),
decoration: BoxDecoration(
color: isDarkTheme ? Colors.black : Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
title != null
? Text(
title,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
)
: SizedBox(),
SizedBox(height: 16),
body != null
? body.toString().startsWith("<")
? Container(
height: 200,
constraints: BoxConstraints(
minHeight: 200, // Minimum height
maxHeight: 500, // Maximum height
),
// width: double.infinity,
child: WebViewWidget(controller: controller!),
)
: Text(body)
: Container(
height: 200,
width: 200,
child: WebViewWidget(controller: controller!),
),
Row(
children: [
Spacer(),
ElevatedButton(
onPressed: () {
Navigator.pop(context);
onOkPressed();
},
child: Text("OK"),
),
],
)
],
),
),
);
},
);
if (url != null) {
controller!.loadRequest(Uri.parse(url!));
}
if (body.toString().startsWith("<")) {
controller!.loadHtmlString(body.toString());
adjustWebviewZoom(scale: scale ?? 4);
}
}