Real-time notification client for OpenNotify — a free, self-hostable, open source notification server for Flutter apps.
This package connects your Flutter app to an OpenNotify server via WebSockets, so notifications arrive instantly — no polling, no third-party push services required.
Looking for the server? → opennotify-server
Add this to your pubspec.yaml:
dependencies:
opennotify_flutter:
git:
url: https://github.com/Abdul20009/opennotify_flutter.gitThen run:
flutter pub getimport 'package:opennotify_flutter/opennotify_flutter.dart';
final client = OpenNotifyClient(
serverUrl: 'http://your-server-url.com',
userId: 'user_123',
);
client.onNotification((notification) {
print('${notification.title}: ${notification.body}');
});
client.connect();Don't forget to disconnect when you're done (e.g. in dispose()):
client.disconnect();Every notification received has the following shape:
class OpenNotification {
final String id;
final String appId;
final String userId;
final String title;
final String body;
final Map<String, dynamic>? data;
final bool read;
final DateTime createdAt;
}Use notification.data to pass custom payloads — e.g. a screen to navigate to, an entity ID, etc.
If your OpenNotify server runs on plain HTTP (not HTTPS), add the following to android/app/src/main/AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:usesCleartextTraffic="true"
...>This package requires an OpenNotify server to connect to. You can self-host one for free in a few minutes — see the server setup guide.
MIT