Summary
When using Appwrite Cloud with the Flutter SDK (latest appwrite release: 21.4.0), Realtime crashes with:
#0 new RealtimeMessage.fromMap (package:appwrite/src/realtime_message.dart:57:47)```
The crash occurs as soon as a real Realtime event (`.create`, `.update`, `.delete`) is received. Heartbeat messages work fine.
This happens before the event reaches the user’s sub.stream.listen(...) callback.
**Environment**
- Appwrite Cloud
- Endpoint: https://cloud.appwrite.io/v1
- Flutter SDK: appwrite: 21.4.0
- Platform: Android (Flutter)
**Root Cause**
Inside the Flutter SDK, RealtimeMessage.fromMap assumes that:
events: List<String>
channels: List<String>
However, under certain conditions, the Realtime WebSocket payload delivers `events` and/or `channels` as a Map instead of a `List`.
Because the SDK strictly casts:
(map['events'] as List)
it throws:
type '_Map<String, dynamic>' is not a subtype of type 'Iterable<dynamic>'
This indicates the parser is not tolerant to slight payload structure variations.
**Reproduction**
Minimal example:
final sub = realtime.subscribe([
'databases.{dbId}.collections.{collectionId}.documents'
]);
sub.stream.listen((event) {
print(event);
});
As soon as a document `.create` or `.update` event is triggered,
the SDK crashes in `RealtimeMessage.fromMap`.