This package helps you to display a notification on macOS platform. You can highly customize this notification.
NOTE: To be able to use this package, you must be on master
Flutter channel.
See Installing
tab to see how to integrate.
Wherever you want to use this plugin, do
import 'package:mac_notifications/mac_notifications.dart';
Here's a basic usage example. See example
folder on (GitHub)[https://github.com/beagle-barks/flutter_mac_notification_plugin/] for more information.
try {
MacNotifications.showNotification(
MacNotificationOptions(
identifier: 'test-notifications',
title: 'Hello',
subtitle: 'This is a notification from Flutter to Mac',
informative:
'And it runs smoothly with almost no cost when implementing ;)',),
);
} on PlatformException {}
try {
MacNotifications.showNotification(
MacNotificationOptions(
identifier: 'test-notifications',
title: 'Hello',
subtitle: 'This is a notification from Flutter to Mac',
informative:
'And it runs smoothly with almost no cost when implementing ;)',
hasReplyButton: true,
replyPlaceholder: 'Your answer goes here',
),
);
} on PlatformException {}
To get the text the user enters in a reply notification, you can simply use a StreamBuilder
or StreamSubscription
.
StreamBuilder<String>(
stream: MacNotifications.getAnswers,
builder: (context, snapshot) {
if (snapshot.data == null)
return Text(
'Your answer goes here.',
style: TextStyle(
fontWeight: FontWeight.bold,
),
);
return Text(
snapshot.data,
style: TextStyle(
fontWeight: FontWeight.bold,
),
);
},
)