showMessage method

Future<void> showMessage({
  1. required String message,
  2. String title = 'Error',
  3. String buttonLabel = 'OK',
})

Show a message with an OK button.

Implementation

Future<void> showMessage({
  required final String message,
  final String title = 'Error',
  final String buttonLabel = 'OK',
}) =>
    showDialog(
      context: this,
      builder: (final context) => AlertDialog(
        actions: [
          TextButton(
            onPressed: () => Navigator.pop(context),
            child: Text(buttonLabel),
          ),
        ],
        title: Text(title),
        content: CallbackShortcuts(
          bindings: {
            const SingleActivator(LogicalKeyboardKey.enter): () =>
                Navigator.pop(context),
          },
          child: Focus(
            autofocus: true,
            child: Text(message),
          ),
        ),
        semanticLabel: message,
      ),
    );