showOkDialog static method
void
showOkDialog(})
Implementation
static void showOkDialog(
BuildContext context, {
required String shape,
String? title,
String? body,
String? url,
int? scale,
Function()? onOkPressed,
}) {
var isDarkTheme = Theme.of(context).brightness == Brightness.dark;
if (showConfetti) {
_confettiController =
ConfettiController(duration: const Duration(seconds: 10));
_confettiController.play();
}
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
backgroundColor: isDarkTheme ? Colors.black : Colors.white,
title: title != null ? Text(title!) : null,
content: SingleChildScrollView(
child: Stack(
children: [
body != null
? body.toString().startsWith("<")
? Container(
height: 200,
width: 200,
child: WebViewWidget(controller: controller!),
)
: Text(body)
: Container(
height: 200,
width: 200,
child: WebViewWidget(controller: controller!),
),
showConfetti
? Container(
height: 250,
width: 250,
child: ConfettiWidget(
confettiController: _confettiController,
blastDirectionality: BlastDirectionality.explosive,
// don't specify a direction, blast randomly
shouldLoop: true,
// start again as soon as the animation is finished
colors: const [
Colors.green,
Colors.blue,
Colors.pink,
Colors.orange,
Colors.purple
],
// manually specify the colors to be used
createParticlePath: drawStar,
),
)
: SizedBox(),
],
),
),
actions: <Widget>[
TextButton(
onPressed: onOkPressed == null
? () {
Navigator.pop(context);
if (showConfetti) {
_confettiController.stop();
}
}
: () {
Navigator.pop(context);
controller!.clearCache();
if (showConfetti) {
_confettiController.stop();
}
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);
}
}