Flutter (Android, iOS, Web)
The DNotifier Dart SDK is a pure Dart package that runs on Flutter for Android, iOS, Web, and desktop targets. No platform channels or native plugins are required in the SDK β WebSocket and HTTP are handled by web_socket_channel and http.
Requirements
β Install β Dart / Flutter
Add the dependency
In pubspec.yaml:
dependencies:
flutter:
sdk: flutter
dnotifier: ^1.1.10flutter pub getCheck pub.dev/packages/dnotifier for the latest version.
Platform support
Target
WebSocket (ws)
HTTP (http)
Notes
Android
β
β
No extra native config
iOS
β
β
App Transport Security allows api.dnotifier.com over TLS
Web
β
β
Uses browser WebSocket via package
Windows / macOS / Linux
β
β
Where Flutter desktop is supported
Connect in a Flutter widget
Run with compile-time defines:
State management
Wrap the DNotifier instance in your preferred pattern:
Provider / Riverpod
Register a singleton service; expose connection state
Bloc / Cubit
Emit events from onMessage; call send from handlers
GetX
Get.put(DNotifierService()) with lifecycle hooks
Keep one connection per authenticated user session. Call disconnect() when the user logs out.
Sending messages
Multiple receivers:
β Your first message β Dart / Flutter
AI and workflows on mobile
Use transport: 'http' for sendAI, knowledge-base APIs, and runWorkflow. Common pattern:
Chat UI β
wsfor realtime messagesAI screen or backend β
httpfor prompts and RAG
You can hold two DNotifier instances with different transports, or route AI through your own API.
Background and lifecycle
AppLifecycleState.paused
Optionally disconnect to save battery
AppLifecycleState.resumed
Reconnect with backoff if disconnected
User logout
disconnect() and dispose the instance
Flutter Web specifics
WebSocket uses the browser's native socket β same behavior as the browser JavaScript guide
Do not embed production secrets in compiled web assets; use
--dart-defineonly for dev or proxy through your backendTest reconnection when the user switches browser tabs
Permissions
The SDK does not require microphone, camera, or notification permissions. Add those in your app only if you build voice, video, or push features on top of DNotifier messaging.
Workflows and agents
Use transport: 'http' and await notifier.runWorkflow(...).
Troubleshooting
Authentication failed
Verify app ID and secret
StateError: Not connected
Await connect() before send()
Works on Android, fails on iOS
Check network / ATS; ensure TLS to api.dnotifier.com
Web build secret exposed
Move auth to backend
β Troubleshooting
Next steps
Last updated