showNativeNotification method

  1. @override
Future<void> showNativeNotification(
  1. String title,
  2. String body, {
  3. String? icon,
  4. bool sound = false,
})
override

Show a native OS notification.

Implementation

@override
Future<void> showNativeNotification(
  String title,
  String body, {
  String? icon,
  bool sound = false,
}) async {
  if (_platform == NativePlatform.macos) {
    final soundPart = sound ? ' sound name "default"' : '';
    final script =
        'display notification "$body" with title "$title"$soundPart';
    await _runSimple('osascript', ['-e', script]);
  } else if (_platform == NativePlatform.linux) {
    final args = <String>[title, body];
    if (icon != null) args.addAll(['-i', icon]);
    await _runSimple('notify-send', args);
  }
}