showNotification static method

Future<void> showNotification({
  1. required String title,
  2. required String body,
  3. String? subtitle,
  4. bool silent = false,
  5. VoidCallback? onShow,
  6. VoidCallback? onClick,
  7. dynamic onClose(
    1. String
    )?,
})

Show a simple desktop notification

Implementation

static Future<void> showNotification({
  required String title,
  required String body,
  String? subtitle,
  bool silent = false,
  VoidCallback? onShow,
  VoidCallback? onClick,
  Function(String)? onClose,
}) async {
  if (!_isDesktopPlatform()) {
    if (kDebugMode) {
      print('NotificationMasterDesktop: Not a desktop platform');
    }
    return;
  }

  if (!_isInitialized) {
    if (kDebugMode) {
      print(
        'NotificationMasterDesktop: Not initialized. Call initialize() first.',
      );
    }
    return;
  }

  try {
    // Implementation with local_notifier
    // LocalNotification notification = LocalNotification(
    //   title: title,
    //   subtitle: subtitle,
    //   body: body,
    //   silent: silent,
    // );
    //
    // if (onShow != null) {
    //   notification.onShow = onShow;
    // }
    //
    // if (onClick != null) {
    //   notification.onClick = onClick;
    // }
    //
    // if (onClose != null) {
    //   notification.onClose = (closeReason) {
    //     onClose(closeReason.name);
    //   };
    // }
    //
    // await notification.show();

    if (kDebugMode) {
      print('NotificationMasterDesktop: Notification shown - $title');
    }
  } catch (e) {
    if (kDebugMode) {
      print('NotificationMasterDesktop: Failed to show notification: $e');
    }
  }
}