showBottomSheet static method
void
showBottomSheet(})
Implementation
static void showBottomSheet(
BuildContext context, {
String? title,
required String? body,
String? background,
String? textColor,
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: background != null
? hexToColor(background)
: isDarkMode
? Colors.black
: Colors.white,
borderRadius: const 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,
color:
textColor != null ? hexToColor(textColor) : null,
),
)
: const SizedBox(),
const SizedBox(height: 16),
body != null
? body.toString().startsWith("<")
? Container(
height: 200,
constraints: const BoxConstraints(
minHeight: 200, // Minimum height
maxHeight: 500, // Maximum height
),
// width: double.infinity,
child: WebViewWidget(controller: controller!),
)
: Text(
body,
style: TextStyle(
color: textColor != null
? hexToColor(textColor)
: null,
),
)
: SizedBox(
height: 200,
width: 200,
child: WebViewWidget(controller: controller!),
),
Row(
children: [
const Spacer(),
ElevatedButton(
onPressed: () {
Navigator.pop(context);
onOkPressed();
},
child: const Text("OK"),
),
],
)
],
),
),
);
},
);
if (url != null) {
controller!.loadRequest(Uri.parse(url));
}
if (body.toString().startsWith("<")) {
controller!.loadHtmlString(body.toString());
adjustWebviewZoom(scale: scale ?? 4);
}
}