show method

Future<void> show()

Shows the native macOS Dialog and calls the specific onPressed handler

WrongPlatformException if .show() was not called on a macOS Platform

Implementation

Future<void> show() async {
  if (!Platform.isMacOS) {
    throw WrongPlatformException("Platform needs to be macOS");
  }

  final result = await _channel.invokeMethod<int>("showDialogMacos", {
        "title": title,
        "message": message,
        "style": style.index,
        "buttons": [for (var button in buttons) button.toJson()]
      }) ??
      -1;
  if (result == -1) return;
  var button = buttons[result];
  if (!button.enabled || button.onPressed == null) return;
  button.onPressed!();
}