show method

Future<void> show({
  1. BuildContext? context,
  2. String? title,
  3. String? msg,
  4. List<Widget>? body,
  5. List<Widget>? actions,
})

Call to display this Message box.

Implementation

Future<void> show({
  BuildContext? context,
  String? title,
  String? msg,
  List<Widget>? body,
  List<Widget>? actions,
}) {
  context = context ?? this.context;
  title = title ?? this.title;
  msg = msg ?? this.msg;
  body = body ?? this.body;
  if (body == null) {
    if (msg == null || msg.isEmpty) {
      body = [const Text('Shall we continue?')];
    } else {
      body = [Text(msg)];
    }
  }
  actions = actions ?? this.actions;
  actions ??= <Widget>[
    TextButton(
      key: const Key('button01'),
      onPressed: () {
        Navigator.pop(context!);
      },
      child: const Text('OK'),
    ),
  ];

  return showDialog<void>(
    context: context,
    barrierDismissible: false,
    builder: (BuildContext context) => AlertDialog(
      title: Text(title ?? ''),
      content: SingleChildScrollView(
        child: ListBody(
          children: body!,
        ),
      ),
      actions: actions,
    ),
  );
}