A Dart FFI package to send 💬 toasts on Windows. Written in C++, based on WinToast.

Overview

desktoasts

A Dart package to send native 💬 toasts on Windows.

Installation

For Flutter

dependencies:
  ...
  desktoasts: ^0.0.2

For Dart CLI

here

Support

Documentation

Initialize the toasts service.

ToastService? service;

void main() {
  service = new ToastService(
    appName: 'desktoasts',
    companyName: 'alexmercerind',
    productName: 'desktoasts_example',
  );
  runApp(MyApp());
}

Show a toast containing subtitle.

Toast toast = new Toast(
  type: ToastType.text02,
  title: 'Hello World!',
  subtitle: 'This toast contains a subtitle.',
);
service?.show(toast);

Show a toast containing an image.

Toast toast = new Toast(
  type: ToastType.imageAndText02,
  title: 'Hello World!',
  subtitle: 'This toast contains an image.',
  image: new File('C:/Windows/Web/Screen/img100.jpg')
);
service?.show(toast);

Show a toast with actions in it.

Toast toast = new Toast(
  type: ToastType.imageAndText02,
  title: 'Hello World!',
  subtitle: 'This toast contains actions in it.',
  image: new File('C:/Windows/Web/Screen/img100.jpg'),
  actions: [
    'Accept',
    'Decline',
  ]
);
service?.show(toast);

Handling events

service?.stream.listen((event) {
  if (event is ToastDismissed) {
    print('Toast was dismissed.');
  }
  if (event is ToastActivated) {
    print('Toast was clicked.');
  }
  if (event is ToastInteracted) {
    print('${event.action} action in the toast was clicked.');
  }
});

Progress

Done.
  • Simple toasts.
  • Toasts with image.
  • Toasts with actions.
  • UTF16 text in toasts.
  • Event handling.
Yet to be done.
  • Progress bar toasts.
  • Large image toasts.
  • Linux support.

CLI

Currently only Flutter plugin is published to the pub.dev.

For sending toasts from Dart console apps, you may do as follows for now.

git clone https://github.com/alexmercerind/desktoasts.git
cd desktoasts/cli/example
dart main.dart

Workings

Although, this might seem like a Flutter plugin, but this is internally based on FFI instead.

This section of the repository, contains C++ code that I compile to a shared library (which both Dart package & Flutter plugin pack along with them) for sending toasts.

Currently, features are limited. I definitely plan to improve upon this.

License

MIT License. Contributions welcomed.

Acknowledgements

Current package's functionality is solely based upon WinToast. Thanks to mohabouje.

You might also like...

A Beautiful Windows 11 UI Built With Flutter

A Beautiful Windows 11 UI Built With Flutter

Windows 11 Redesign Depois de um tempo sem trabalhar com Flutter decidi fazer uma interface baseado no Windows 11, espero que vocês gostem e deixem o

Dec 1, 2022

🎵 Elegant music app to play local music & YouTube music. Distributes music into albums & artists. Has playlists & lyrics. Windows + Linux + Android.

🎵 Elegant music app to play local music & YouTube music. Distributes music into albums & artists. Has playlists & lyrics. Windows + Linux + Android.

Harmonoid Elegant music app to play local music & YouTube music. Download Now 🏁 Windows, Linux & Android. Feel free to report bugs & issues. Loving t

Aug 10, 2022

Dart package to rank proposals according to Majority Judgment, using a score-based algorithm for performance and scalability

Majority Judgment for Dart This Dart package helps to resolve polls using Majority Judgment. Features Efficient Majority Judgment algorithm, scales we

Oct 18, 2021

This is a fully fledged Sudoku game written in Dart using Flutter.

This is a fully fledged Sudoku game written in Dart using Flutter.

This is a fully fledged Sudoku game written in Dart using Flutter.

Dec 29, 2022

Simple URL-shorter written in Dart with Notion as a database

Simple URL-shorter written in Dart with Notion as a database

Tuda A simple URL-shorter service written in pure Dart. With Notion as a database, it provides the simplest interface for setting your links. Environm

Aug 19, 2022

Elpee is a multiplatform app written entirely in Dart/Flutter.

Elpee is a multiplatform app written entirely in Dart/Flutter.

elpee - Explore and share music About Elpee is a multiplatform app written entirely in Dart/Flutter. The data is retrieved from the Spotify Web API an

Oct 25, 2022

The Fuse Wallet is a cross platform Ethereum wallet written in Dart and built on Flutter.

Fuse Wallet The Fuse Wallet is a cross platform Ethereum wallet written in Dart and built on Flutter. It's runninng on the Fuse network, but can be pl

Nov 9, 2022

Figma API client written in pure Dart

figma A library for interacting with Figma APIs. Created from templates made available by Stagehand under a BSD-style license. Usage A simple usage ex

Oct 19, 2022

An equation solving library written purely in Dart.

An equation solving library written purely in Dart Thanks to the equations package you will be able to solve numerical analysis problems with ease. It

Dec 27, 2022
Comments
  • [Proposal] Use native source code instead of FFI

    [Proposal] Use native source code instead of FFI

    Hello, this library is great. It is the only library that supports Windows notifications.

    I have a few thoughts to talk about. I looked at your source code and directly packaged a desktoasts.dll, which was called by FFI on the Dart layer.

    I personally think that Flutter's FFI is mainly aimed at application, not package and plugin. In plugins, it is only a trick to call dynamic libraries through path splicing.

    Using FFI in a plug-in will cause many problems, and the most serious one I have found so far is the inability to coexist with the web platform. Of course, Dart has if (dart.library.ffi), but this operation needs to be done manually by the user, which is very bad, and this part of the code will also be compiled to other platforms.

    So I want to know, is it possible to implement this plug-in using platform source code? Instead of precompiled as a dynamic library

    enhancement 
    opened by ggdream 3
  • App shutting down on dismiss

    App shutting down on dismiss

    Hello,

    I am developing an application on Windows 10. The notification is working well, but whenever I click on the close button, send the notification to the notification center, open it and click on the close button again to totally dismiss the notification from the notification center the application crashes.

    I tried to make the notification not appear in the notification center using windows settings, but if I do it this way then the application will crash the first time I close and dismiss the notification.

    opened by Yanis01 0
  • What to specify in the appName, companyName and productName?

    What to specify in the appName, companyName and productName?

    Hi! Thank you for a such great component. Could you please tell, is it important what I pass to the ToastService(...) via appName, companyName and productName variables?

    My application started crashing on startup (when the ToastService is registered) after adding this component, but it doesn't crash every time I start it - only sometimes. I'm wondering if this could be due to the fact that the information passed to the ToastService is not reliable for Windows?

    I tried to run the app with the -v flag, however it's impossible to understand what's wrong with the app:

    [  +16 ms] 
       #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
       #1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:663:9)
       
       #2      FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart:1043:27)
       
       #3      AppContext.run. (package:flutter_tools/src/base/context.dart:150:19)
       
       #4      CommandRunner.runCommand (package:args/command_runner.dart:196:13)
       
       #5      FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9)
       
       #6      AppContext.run. (package:flutter_tools/src/base/context.dart:150:19)
       
       #7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5)
       
       #8      run.. (package:flutter_tools/runner.dart:62:9)
       
       #9      AppContext.run. (package:flutter_tools/src/base/context.dart:150:19)
       
       #10     main (package:flutter_tools/executable.dart:91:3)
       
    
    opened by alexursul 1
Owner
Hitesh Kumar Saini
Flutter & React.js developer. Writes C++, Dart, JS & Python. Maintains few utility libraries. Designs beautiful UIs.
Hitesh Kumar Saini
Send WhatsApp Messages without saving contact

WHATSAPP DIRECT Send WhatsApp Messages without saving contact Installation PlayStore Link: https://play.google.com/store/apps/details?id=com.snapsid.w

Siddharth Chopra 1 Oct 2, 2022
A Flutter Send SMS App

flutter_send_sms A new Flutter Send SMS application. Getting Started For help getting started with Flutter, view our online documentation, which offer

Ahmer Iqbal 1 Jul 25, 2022
For flutter native plugins, send event to main thread.

native_main_thread A new Flutter plugin. Getting Started This project is a starting point for a Flutter plug-in package, a specialized package that in

null 0 Nov 26, 2021
This app developed for making fun with sms. You can send huge sms to other's number by one click. It is behaving like a bomb

SMS Bomber This app developed for making fun with sms. You can send huge sms to other's number by one click. It is behaving like a bomb Getting Starte

Md Abir Ahsan Tahmim 1 Dec 21, 2021
Test telegram bot written in dart using teledart package

Dart-Tg-Bot Test telegram bot written in dart using teledart package. Run on local machine First install dart Clone the bot's source and install depen

I'm Not A Bot #Left_TG 8 Oct 31, 2022
A cross-platform (Android/Windows/macOS/Linux) USB plugin for Flutter

quick_usb A cross-platform (Android/Windows/macOS/Linux) USB plugin for Flutter Usage List devices List devices with additional description Get device

Woodemi Co., Ltd 39 Oct 1, 2022
A Flutter plugin to read 🔖 metadata of 🎵 media files. Supports Windows, Linux & Android.

flutter_media_metadata A Flutter plugin to read metadata of media files. A part of Harmonoid open source project ?? Install Add in your pubspec.yaml.

Harmonoid 60 Dec 2, 2022
Flutter window blur & transparency effects for on Windows & Linux. 💙

flutter_acrylic Window blur & transparency effects for Flutter on Windows & Linux Installation Mention in your pubspec.yaml. dependencies: ... flu

Hitesh Kumar Saini 438 Jan 2, 2023
Music reader for online data (Google Drive implementation). Cross platform goal : iOS, Android, MacOS, Windows

omusic A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this i

JeanNicolasdeLamballerie 0 Nov 30, 2021
A Flutter plugin for handling Connectivity and REAL Connection state in the mobile, web and desktop platforms. Supports iOS, Android, Web, Windows, Linux and macOS.

cross_connectivity A Flutter plugin for handling Connectivity and REAL Connection state in the mobile, web and desktop platforms. Supports iOS, Androi

MarchDev Toolkit 29 Nov 15, 2022