Viewing version 3.1.1. Open the latest package page.
flutter_local_notifications_windows
3.1.1Windows implementation of the flutter_local_notifications plugin
Readme
flutter_local_notifications_windows
The Windows implementation of package:flutter_local_notifications as an FFI package that can be run in plain Dart or as a Flutter plugin. See the docs on FFI.
Limitations
- Windows does not support repeating notifications, so
periodicallyShowandperiodicallyShowWithDurationwill throwUnsupportedErrors. - Windows only allows apps with package identity to retrieve previously shown notifications. This means that on an app that was not packaged as an MSIX installer,
canceldoes nothing and getActiveNotifications will return an empty list. To package your app as an MSIX, seepackage:msixand themsixsection in the example'spubspec.yaml.
Project structure
This template uses the following structure:
-
src: Contains the native source code, and a CmakeFile.txt file for building that source code into a dynamic library. Within this folder, there are three C++ files:ffi_api.h/ffi_api.cpp: A C-compatible header file with the API that will be used by Dart, and the C++ implementation of that APIplugin.hpp/plugin.cpp: A C++ class holding handles to the C++/WinRT SDK, along with some Windows-heavy logic.ffi_api.cppimplements its features using this class.utils.hpp/utils.cpphandle copying and allocating data from C structs to WinRT classes and vice-versa. Since FFI is done over C-based APIs, C++ types like strings, maps, and vectors need to be translated.
-
lib: Contains the Dart code that defines the API of the plugin, and which calls into the native code usingdart:ffi.- The
detailsfolder holds all the Windows-specific notification configurations such asWindowsAction,WindowsImage, etc. - The
ffifolder holds the generated bindings (see below) and other FFI utilities. - The
pluginfolder implementspackage:flutter_local_notifications_platform_interfacein two ways: a stub for platforms that don't support FFI, and an FFI-based implementation.
- The
-
The
windowsfolder contains the build files for building and bundling the native code library with the platform application.
Building and bundling native code
The code in src can be built with CMake. A build.bat file is included, which has the following code:
@echo off
cd build
cmake ../windows
cmake --build .
cd ..
copy build\shared\Debug\flutter_local_notifications_windows.dll .
This generates a DLL from the native code and copies it to the current directory. This is useful for testing locally without Flutter. When using Flutter, this step is unnecessary as Flutter will build and bundle the assets for you.
Binding to native code
To use the native code, bindings in Dart are needed.
To avoid writing these by hand, they are generated from the header file
src/ffi_api.h by package:ffigen.
Regenerate the bindings by running dart run ffigen --config ffigen.yaml.
Changelog
[3.1.1]
- Suppress warning around usage of experimental coroutines. This is to fix issue #2777
[3.1.0]
- Updated
periodicallyShow()to acceptpayloadandnotificationDetailsas optional parameters - Bumped
xmldependency so that supported range is>=6.5.0 <8.0.0 - Bumped dependency on
flutter_local_notifications_platform_interface
[3.0.0]
- Breaking change bumped minimum Flutter SDK requirement to 3.38.1 and Dart SDK requirement to 3.10.0
- Bumped
timezonedependency
[2.0.1]
- Non-functional change: addressed the
use_null_aware_elementslinter issue
[2.0.0]
- Breaking change bumped minimum Flutter SDK requirement to 3.32.0 and Dart SDK requirement to 3.8.0
- Breaking changes the positional parameters in the following methods have now been converted to named parameters
initialize()show()showRawXml()periodicallyShow()periodicallyShowWithDuration()cancel()zonedSchedule()zonedScheduleRawXml()
- Breaking changes to align with the main the plugin, the following parameters have been renamed
- the
detailsparameter in theshow()andzonedSchedule()methods has been renamed tonotificationDetails - the
onNotificationReceivedin theinitialize()method has been renamed toonDidReceiveNotificationResponse
- the
- Breaking change removed the
detailsparameter from thezonedScheduleRawXml()method as it was not actually used. Thanks to the PR from Levi Lesches - Bumped
ffigenand regenerated bindings. Credits to Levi Lesches who originally looked at this before the plugin had its minimum Flutter version bumped - Added
flutter_lintsto apply linter rules
[1.0.3]
- Fixed issue where non-ASCII characters for the notification application name weren't being displayed properly. Thanks to the PR from yoyoIU
[1.0.2]
- Fixed issue #2648 where non-ASCII characters in the notification payload were not being handled properly. Thanks to the PR from yoyoIU
[1.0.1]
- Fixed issue #2651 where unresolved symbols occurred with changes in introduced in newer Windows SDKs. Thanks to the PR from Sebastien
[1.0.0]
- Initial release for Windows. Thanks to PR Levi Lesches that continued the work done initially done by Kenneth and lightrabbit
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add 'flutter_local_notifications_windows:3.1.1'pubspec.yaml
name: flutter_local_notifications_windows
description: Windows implementation of the flutter_local_notifications plugin
version: 3.1.1
homepage: https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications_windows
issue_tracker: https://github.com/MaikuB/flutter_local_notifications/issues
environment:
sdk: ^3.10.0
flutter: ">=3.38.1"
dependencies:
flutter:
sdk: flutter
ffi: ^2.1.2
flutter_local_notifications_platform_interface: ^12.0.0
meta: ^1.11.0
timezone: ^0.11.0
xml: ">=6.5.0 <8.0.0"
dev_dependencies:
ffigen: ^20.1.1
flutter_lints: ^6.0.0
test: ^1.25.2
flutter:
plugin:
implements: flutter_local_notifications
platforms:
windows:
ffiPlugin: true
dartPluginClass: FlutterLocalNotificationsWindows
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 1.0.0-dev.1 | On demand | Download | 0888485c…892522 |
| 1.0.0-dev.2 | On demand | Download | 181b45d2…4b8212 |
| 1.0.0-dev.3 | On demand | Download | 282bb8af…4419e4 |
| 1.0.0-dev.4 | On demand | Download | 3fcc00dc…1cb5a2 |
| 1.0.0 | On demand | Download | f8fc0652…773e6e |
| 1.0.1 | On demand | Download | 593625e6…540d86 |
| 1.0.2 | On demand | Download | ed46d7ae…74ec98 |
| 1.0.3 | On demand | Download | 8d658f0d…668aaf |
| 2.0.0-dev.1 | On demand | Download | d42ed88f…64f80d |
| 2.0.0-dev.2 | On demand | Download | 6f794ec3…fda86c |
| 2.0.0-dev.3 | On demand | Download | aa1bc3f7…92f44b |
| 2.0.0 | On demand | Download | 7ddd964f…46da61 |
| 2.0.1 | On demand | Download | e97a1a30…56b02a |
| 3.0.0-dev.1 | On demand | Download | e7136082…2384d4 |
| 3.0.0 | On demand | Download | 3a2654ba…1bef0c |
| 3.1.0-dev.1 | On demand | Download | 0fb30300…dceb96 |
| 3.1.0-dev.2 | On demand | Download | 2ec0b816…1b145e |
| 3.1.0 | On demand | Download | 5aeed973…5201e1 |
| 3.1.1 | Cached · Upstream SHA-256 matched | Download | 6f43bdd0…382945 |
| 4.0.0-dev.1 | On demand | Download | 048c2efd…1e71cb |
| 4.0.0-dev.2 | On demand | Download | 9eea91ae…7a870b |
Dependencies
ffi "^2.1.2"
flutter {
"sdk": "flutter"
}
flutter_local_notifications_platform_interface "^12.0.0"
meta "^1.11.0"
timezone "^0.11.0"
xml "\u003e=6.5.0 \u003c8.0.0"