Back

I can't seem to get realtime to work on Flutter

  • 0
  • Flutter
  • Realtime
nebukadnezar
7 Apr, 2025, 19:02

As the title says, I've been running the code from the example to learn how to use it (and eventually I want to use a stream builder). I can't seem to get it working though. Here's my code:

TypeScript
void main() {
  WidgetsFlutterBinding.ensureInitialized();

  final client =
      Client()
        ..setEndpoint('https://cloud.appwrite.io/v1')
        ..setProject('<omitted>');

  final realtime = Realtime(client);

  final subscription = realtime.subscribe([
    'databases.<omitted>.collections.<omitted>.documents',
  ]);

  subscription.stream.listen((response) {
    // Callback will be executed on changes for documents A and all files.
    print(response.payload.entries.length);
  });
}

The only thing it outputs is:

TypeScript
flutter: subscription: wss://cloud.appwrite.io/v1/realtime?project=<omitted>&channels%5B%5D=databases.<omitted>.collections.<omitted>.documents
15
flutter: Received heartbeat response from realtime server
TL;DR
Developers are having trouble getting realtime to work on a Flutter project, despite following the example code. The code provided seems to set everything up correctly, but the expected output is not appearing. Solution: A possible reason for this issue could be related to the network setup or the specific configuration of the Appwrite service. Double-check the network connectivity and ensure that the Appwrite service is configured correctly. If the issue persists, consider reaching out to Appwrite support for further assistance.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more