streamData2 method
Widget
streamData2({})
override
Implementation
@override
Widget streamData2({
required dynamic snapshot,
required Widget Function(List<Map<String, dynamic>> resultList) consumerFunc,
bool hasPage = false,
}) {
// appwrite 에서는 일단은 ...사용되지 않는다.
return StreamBuilder<QuerySnapshot>(
stream: snapshot,
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
}
switch (snapshot.connectionState) {
case ConnectionState.waiting:
return const Text('Loading...');
default:
logger.finest('streamData : ${snapshot.data!.docs.length} data founded');
// 마지막 문서 업데이트 (페이징을 위해)
if (hasPage) {
startAfter = snapshot.data!.docs.isNotEmpty ? snapshot.data!.docs.last : null;
}
return consumerFunc(snapshot.data!.docs.map((doc) {
return doc.data() as Map<String, dynamic>;
}).toList());
}
},
);
}