flutter_local_notifications_windows

v1.0.3

Windows implementation of the flutter_local_notifications plugin

Архив пакета: https://pubdev.letsnova.ru/api/archives/flutter_local_notifications_windows/1.0.3.tar.gz

Установкаdart pub add flutter_local_notifications_windows

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

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 API
    • plugin.hpp/plugin.cpp: A C++ class holding handles to the C++/WinRT SDK, along with some Windows-heavy logic. ffi_api.cpp implements its features using this class.
    • utils.hpp/utils.cpp handle 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 using dart:ffi.

    • The details folder holds all the Windows-specific notification configurations such as WindowsAction, WindowsImage, etc.
    • The ffi folder holds the generated bindings (see below) and other FFI utilities.
    • The plugin folder implements package:flutter_local_notifications_platform_interface in two ways: a stub for platforms that don't support FFI, and an FFI-based implementation.
  • The windows folder 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.

История изменений

[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]