can anyone convert this function and body to stream builder i want to get countinous updated data instead of one time calling (Streambuilder instead of Futurebuilder)
issue: with this future builder is when something is change on the database its refresh the whole list
Function
Future fetch() async {
final session = await account.get();
sessionid = session.$id;
final documentList = await databases.listDocuments(
databaseId: '123456789',
collectionId: '123456789',
queries: [
Query.orderDesc('\$id'),
Query.limit(25),
]);
final documents = documentList.documents;
items.clear();
items.addAll(documents.map((doc) {
final epTitle = doc.data['epTitle'];
final epNo = doc.data['epNo'];
final epDuration = doc.data['epDuration'];
return {
...doc.data,
'epTitle': epTitle,
'epNo': epNo,
'epDuration': epDuration,
};
}));
}
Body
FutureBuilder(
future: fetch(),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
return Text('waiting');
} else if (snapshot.hasError) {
checkInternet();
return Text('${snapshot.error}');
} else if (snapshot.connectionState ==
ConnectionState.done) {
return ListView.builder(
itemCount: snapshot.length,
itemBuilder: (context, index) {
//list data
});
} else{
return Text('something went wrong');
}}
);
i searched nothing found