#[SOLVED] how to connect with realtime in flutter

42 messages · Page 1 of 1 (latest)

worldly harbor
#

tried this example but not working
import 'package:appwrite/appwrite.dart';

final client = Client()
.setEndpoint('https://[HOSTNAME_OR_IP]/v1')
.setProject('[PROJECT_ID]');

final realtime = Realtime(client);

// Subscribe to files channel
final subscription = realtime.subscribe(['files']);

subscription.stream.listen((response) {
if(response.events.contains('buckets..files..create')) {
// Log when a new file is uploaded
print(response.payload);
}
});

idle crag
worldly harbor
# idle crag And whats the problem? That string in contains looks wrong btw. Btw, it's best...

Here is how i am implementing realtime in flutter, its just giving subscription in console and nothing is printing in console. except this
subscription: http://192.168.29.63/realtime?project=64386b13977ba3c49d06&channels[]=databases.6439e7ae4abb3e14f2b1.collections.6439e7dd6c9e8a193946.documents
calling this method in side init and also i have double checked database id and collection id,
MyData() async {
try {
final res = await db.listDocuments(
databaseId: '6439e7ae4abb3e14f2b1',
collectionId: collectionId,
queries: [
Query.limit(10000),
//Query.equal(attribute, value)
]
);
setState(() {
items = res.documents.toList(); // Convert to list
});
} on AppwriteException catch (e) {
print(e.message);
}
}

final realtime = Realtime(client).subscribe([
    'databases.6439e7ae4abb3e14f2b1.collections.6439e7dd6c9e8a193946.documents']);

Future<void> subscribeRealtime() async {
await realtime.stream.listen((response) {
print(response.events);// nothing is printing
if (response.events.contains('documents.create')) {
Document document = response.payload as Document;
setState(() {
items.add(document);
});
} else if (response.events.contains('documents.delete')) {
Document document = response.payload as Document;
setState(() {
items.removeWhere((item) => item.appwriteDocumnetId == document.data['$id']);
});
}
}, onError: (error) {
print(error);
});
}

worldly harbor
#

i did not understand what do you mean by ,can you please point out specific line, if you can

idle crag
idle crag
worldly harbor
#
    try {
      final res = await db.listDocuments(
        databaseId: '6439e7ae4abb3e14f2b1',
        collectionId: collectionId,
        queries: [
          Query.limit(10000),
          //Query.equal(attribute, value)
        ]
      );
      setState(() {
        items = res.documents.toList(); // Convert to list
      });
    } on AppwriteException catch (e) {
      print(e.message);
    }
  }

    final realtime = Realtime(client).subscribe([
        'databases.6439e7ae4abb3e14f2b1.collections.6439e7dd6c9e8a193946.documents']);

  Future<void> subscribeRealtime() async {
    await realtime.stream.listen((response) {
      print(response.events);// nothing is printing 
      if (response.events.contains('documents.create')) {
        Document document = response.payload as Document;
        setState(() {
          items.add(document);
        });
      } else if (response.events.contains('documents.delete')) {
        Document document = response.payload as Document;
        setState(() {
          items.removeWhere((item) => item.appwriteDocumnetId == document.data['$id']);
        });
      }
    }, onError: (error) {
      print(error);
    });
  }```
idle crag
worldly harbor
idle crag
worldly harbor
#

like this way

worldly harbor
idle crag
worldly harbor
idle crag
idle crag
worldly harbor
idle crag
worldly harbor
idle crag
idle crag
worldly harbor
worldly harbor
idle crag
idle crag
worldly harbor
worldly harbor
idle crag
worldly harbor
idle crag
idle crag
worldly harbor
# idle crag Please share the url of this page

and also intialize this two time one for run time and second for constant when ever i need to call client client.setEndpoint('http://192.168.29.63 /v1') .setEndPointRealtime('http://192.168.29.63') .setProject('64386b13977ba3c49d06') .setSelfSigned(status: true);

idle crag
worldly harbor
idle crag
idle crag
worldly harbor
idle crag
#

[SOLVED] how to connect with realtime in flutter