streamData2 method

  1. @override
Widget streamData2({
  1. required dynamic snapshot,
  2. required Widget consumerFunc(
    1. List<Map<String, dynamic>> resultList
    ),
  3. Map<String, dynamic>? where,
  4. bool hasPage = false,
})
override

Implementation

@override
Widget streamData2({
  required dynamic snapshot,
  required Widget Function(List<Map<String, dynamic>> resultList) consumerFunc,
  Map<String, dynamic>? where,
  bool hasPage = false,
}) {
  return StreamBuilder<List<Map<String, dynamic>>>(
    stream: snapshot,
    builder: (context, snapshot) {
      if (snapshot.hasError) {
        return Text('Error: ${snapshot.error}');
      }
      switch (snapshot.connectionState) {
        case ConnectionState.waiting:
          return const Text('Loading...');
        default:
          //print('streamData :  ${snapshot.data!.length} data founded');

          // 마지막 문서 업데이트 (페이징을 위해)
          // if (hasPage) {
          //   startAfter = snapshot.data!.isNotEmpty ? snapshot.data!.last : null;
          // }

          return consumerFunc(filterSnapshotData(snapshot.data!, where));
      }
    },
  );
}