showOk function

dynamic showOk({
  1. required BuildContext context,
  2. required String title,
  3. required String content,
})

Implementation

showOk({
  required BuildContext context,
  required String title,
  required String content,
}) {
  // Set up the OKAY button

  Widget okButton = TextButton(
    child: const Text('OK'),
    onPressed: () {
      // Dismiss the dialog
      Navigator.of(context).pop();
    },
  );

  // Set up the AlertDialog

  AlertDialog alert = AlertDialog(
    title: Row(
      children: [
        const Icon(Icons.warning, color: Colors.red),
        const SizedBox(width: 20),
        Text(title),
      ],
    ),
    content: MarkdownBody(
      data: wordWrap(content),
      selectable: true,
      softLineBreak: true,
    ),
    actions: [
      okButton,
    ],
  );

  // Show the dialog

  showDialog(
    context: context,
    builder: (BuildContext context) {
      return alert;
    },
  );
}