local_notifier
March 23, 2025 · View on GitHub
🚀 快速发布您的应用: 试试 Fastforge - 构建、打包和分发您的 Flutter 应用最简单的方式。
local_notifier
这个插件允许 Flutter 桌面 应用显示本地通知。
English | 简体中文
平台支持
| Linux | macOS | Windows |
|---|---|---|
| ✔️ | ✔️ | ✔️ |
截图
| macOS | Linux | Windows |
|---|---|---|
![]() | ![]() | ![]() |
快速开始
安装
将此添加到你的软件包的 pubspec.yaml 文件:
dependencies:
local_notifier: ^0.1.6
或
dependencies:
local_notifier:
git:
url: https://github.com/leanflutter/local_notifier.git
ref: main
Linux requirements
libnotify
运行以下命令
sudo apt-get install libnotify-dev
用法
// 在 main 方法中添加。
await localNotifier.setup(
appName: 'local_notifier_example',
// 参数 shortcutPolicy 仅适用于 Windows
shortcutPolicy: ShortcutPolicy.requireCreate,
);
LocalNotification notification = LocalNotification(
title: "local_notifier_example",
body: "hello flutter!",
);
notification.onShow = () {
print('onShow ${notification.identifier}');
};
notification.onClose = (closeReason) {
// 只支持在windows,其他平台 closeReason 始终为 unknown。
switch (closeReason) {
case LocalNotificationCloseReason.userCanceled:
// do something
break;
case LocalNotificationCloseReason.timedOut:
// do something
break;
default:
}
print('onClose ${_exampleNotification?.identifier} - $closeReason');
};
notification.onClick = () {
print('onClick ${notification.identifier}');
};
notification?.onClickAction = (actionIndex) {
print('onClickAction ${notification?.identifier} - $actionIndex');
};
notification.show();
请看这个插件的示例应用,以了解完整的例子。
谁在用使用它?
- Biyi (比译) - 一个便捷的翻译和词典应用。


