desktoasts 0.0.2 desktoasts: ^0.0.2 copied to clipboard
A plugin to show native toasts on Windows.
desktoasts
A Dart package to send native 💬 toasts on Windows.
Installation #
For Flutter
dependencies:
...
desktoasts: ^0.0.2
For Dart CLI
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.