Flutter Local Notifications plugin
This repository consists hosts the following packages
flutter_local_notifications: code for the cross-platform facing plugin used to display local notifications within Flutter applicationsflutter_local_notifications_platform_interface: the code for the common platform interface
These can be found in the corresponding directories within the same name. Most developers are likely here as they are looking to use the flutter_local_notifications plugin. There is a readme file within each directory with more information.
Issues
If you run into bugs, please raise them on the GitHub repository. Please do not email them to me as GitHub is the appropriate place for them and allows for members of the community to answer questions, particularly if I miss the email. It would also be much appreciated if they could be limited to actual bugs or feature requests. If you’re looking at how you could use the plugin to do a particular kind of notification, check the example app provides detailed code samples for each supported feature. Also try to check the README first in case you have missed something e.g. platform-specific setup.
Contributions
Contributions are welcome by submitting a PR for to be reviewed. If it’s to add new features, appreciate it if you could try to maintain the architecture or try to improve on it. If you are looking to add platform-specific functionality do not add this to the cross-platform facing API (i.e. the FlutterLocalNotificationsPlugin class. The recommended approaches in this scenario are:
see if it can be passed as platform-specific configuration or add methods to the platform-specific implementations. For example, on iOS there is an IOSFlutterLocalNotificationsPlugin class. You may notice there’s a requestPermissions() method that only exists there
Download Flutter Local Notifications plugin source code on GitHub
A Flutter plugin for displaying local notifications on Android, iOS, macOS, Linux and Windows https://github.com/MaikuB/flutter_local_notifications 1,577 forks. 2,670 stars. 135 open issues. Recent commits: Clang format , github-actions[bot] [flutter_local_notifications_windows] handle activation without arguments (#2872)* [flutter_local_notifications_windows] handle activation without argumentsActivate already treats a null args as a plain notification launch, but still built the payload with string(CW2A(args)). CW2A of a null string yields a null char*, and constructing std::string from it is undefined behaviour (an access violation that catch (…) does not catch without /EHa). Use an empty payload instead.* [flutter_local_notifications_windows] pass a null payload from native code and coalesce it in DartWhen the toast has no launch arguments, native code now sets the payload to nullptr. Dart maps it to an empty string in one helper, so returning null later is a one-line change.* [flutter_local_notifications_windows] treat empty activation arguments as no payloadA toast without a launch attribute is activated with an empty string, not a null pointer, so the native side now sends a null payload in that case too. , GitHub [flutter_local_notifications_windows] free callback map strings with delete[] (#2869)toNativeString allocates every key and value of the launch details map with new char[], but freeLaunchDetails released them with scalar delete. Mismatched new[]/delete is undefined behaviour (AddressSanitizer reports it as alloc-dealloc-mismatch when that check is enabled), and it runs on every activation that carries user input. , GitHub [windows] run every WinRT call on a dedicated worker thread (#2826)* [windows] run every WinRT call on a dedicated worker threadToastNotificationManager talks to the Windows notification service over COM.On a machine whose service is unhealthy that call blocks for minutes, andbecause the plugin ran it on the thread that hosts the Flutter engine, thewhole app froze – no frames, no input, near-zero CPU. A user of an app of ourssaw ten-minute freezes on every launch, and a captured stack showed the UIthread parked in wpnapps.dll under combase.The plugin now owns one worker thread with its own multi-threaded apartmentand runs every WinRT call there. init, show, schedule and the cancels arequeued and return immediately; the two queries that must return data stillwait for the worker. A multi-threaded apartment is used deliberately: itbelongs to the process rather than to a thread, so the notifier handles andthe CoRegisterClassObject registration stay valid.Since work is queued, the readiness check moved from the caller into each job,and the strings a caller passes – which belong to a Dart arena freed when thecall returns – are copied before queueing.* Fix Windows notification worker invoke deadlock* windows: construct worker thread after its queue and mutexMembers are initialized in declaration order, so declaring the std::thread first let the worker run and lock the mutex, wait on the condition variable and read the queue before they were constructed. Declare the thread last so it starts only after every member it uses exists; it is also destroyed first, after the destructor has already joined it.* windows: release WinRT handles on the worker before it stopsNativePlugin declares its worker after the ToastNotifier and ToastNotificationHistory handles, so the worker is destroyed first and uninitializes its apartment before those handles are released on the calling thread. disposePlugin after a successful init then crashed with an access violation.The destructor now releases both handles on the worker while its apartment is still alive, and revokes the activation class object, whose registration cookie was previously discarded.* windows: scheduling replaces a toast with the same id; cancel removes every matchscheduleNotification added a new scheduled toast without removing an existing one with the same tag, and cancelNotification removed only the first scheduled toast with that tag. Scheduling the same id twice therefore left a duplicate that survived cancel. Both now remove every scheduled toast with the tag, collected before removal.* windows: address review on the worker-thread change- Query results: collect ids first and publish the array and count only once complete; tags that are not integers are skipped.- showNotification/scheduleNotification validate the XML before queueing, so showRawXml throws ArgumentError on malformed XML again.- disposePlugin hands teardown to a thread that owns the plugin, so a worker stuck in a COM call cannot block the Flutter thread.- Validate the GUID before createPlugin starts the worker thread.* Clang format* windows: report initialization result and show late schedules`initialize()` again resolves with whether native initializationsucceeded, without blocking the calling thread: the worker reports theresult through a one-shot `NativeInitCallback`. Concurrent calls sharethe pending result, and `dispose()` while pending releases the pluginonce the queued init has run.A scheduled toast whose time has passed by the time its job runs (forexample behind a stalled call) is now shown immediately, since`AddToSchedule` throws for a past delivery time.* windows: keep initialize consistent when queueing init throwsPending state is set only once both callbacks exist, and a synchronous failure while queueing init resolves the pending call and releases the plugin before rethrowing.* fix(windows): preserve signed 64-bit schedule timestamps* windows: cancelAll removes scheduled toasts after iterating themcancelAll now uses removeScheduled, which collects matches before removing, instead of removing from the scheduled view while iterating it. Also notes how to run the manual timestamp ABI probe.———Co-authored-by: ypl <7353755@gmail.com> , GitHub [flutter_local_notifications_windows] Feature parity for Windows apps without package identity (#2801)* feat: [Windows] Add support for canceling individual notifications and getting active notifications without requiring MSIX packaging* Remove limitation in README* Configurable group name* Fix cancel and getActiveNotifications for non-MSIX apps.* Clang format* Bound group name and throw if bad name when no identity* Reject partial tag matches* Remove outdated comments* Same stoi check in getPendingNotifications* Fix group validation retries and legacy notification updates* Clang format* Free notification history buffer when enumeration fails* fix edge case* Remove fallback* Clang format , GitHub
Provides the list of the opensource Flutter apps collection with GitHub repository.