appwrite / appwrite/sdk-for-flutter
🐛 Bug Report: realtimeMessage.fromMap crashes with _Map<String, dynamic> is not a subtype of Iterable<dynamic>
- Dominant language
- Dart
- Stars
- 418
- Forks
- 150
- Avg merge
- 1h 23m
- Merged PRs (30d)
- 3
Description
### 👟 Reproduction steps
1. Set up an Appwrite Realtime subscription on a collection/document channel (e.g., messaging).
2. Trigger a document creation event (e.g., send a message that creates a document in the subscribed collection).
3. The Realtime WebSocket receives the event of type `"event"`.
4. The SDK attempts to parse the incoming event data via `RealtimeMessage.fromMap()`.
5. The app crashes with an unhandled exception.
### 👍 Expected behavior
The `RealtimeMessage.fromMap()` factory constructor should correctly parse the incoming WebSocket event data regardless of whether the server sends `events` or `channels` as a `List` or a `Map`. The Realtime subscription callback should fire with a valid `RealtimeMessage` object containing the event payload.
### 👎 Actual Behavior
```
E/flutter (16642): [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: type '_Map' is not a subtype of type 'Iterable'
E/flutter (16642): #0 new RealtimeMessage.fromMap (package:appwrite/src/realtime_message.dart:57:47)
E/flutter (16642): #1 RealtimeMixin._createSocket. (package:appwrite/src/realtime_mixin.dart:100:45)
E/flutter (16642): #2 _RootZone.runUnaryGuarded (dart:async/zone.dart:1778:10)
...
```
### 🎲 Appwrite version
Version 2.0.x
### 💻 Operating system
Windows
### 🧱 Your Environment
Flutter app using BLoC pattern for state management
Appwrite Realtime subscriptions on tablesdb/tables channels
Standard Appwrite Cloud
### 👀 Have you spent some time to check if this issue has been raised before?
- [x] I checked and didn't find similar issue
### 🏢 Have you read the Code of Conduct?
- [x] I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)
Contributor guide
Assessment
This issue has not been assessed yet.