Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- return StreamBuilder<QuerySnapshot>(
- stream: communityBloc.feedStream,
- builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {
- if (snapshot.hasError) {
- debugPrint('Snapshot error: ${snapshot.error}');
- return Text('error');
- }
- if (snapshot.connectionState == ConnectionState.none)
- return Text('stream is null, connection = none');
- if (snapshot.connectionState == ConnectionState.waiting)
- return UIUtils.Spinner();
- if (snapshot.data == null || snapshot.data.documents.length == 0) {
- return Text('no data');
- }
- return Provider(
- builder: (_) => ActivityPreviewBloc(
- Provider.of<AuthenticationBloc>(context).authenticatedUserUID),
- dispose: (_, bloc) => bloc.dispose(),
- child: ListView.builder(
- addAutomaticKeepAlives: true, // TODO review this
- itemBuilder: (context, index) => ActivityPreview(
- Activity.fromJson(
- Provider.of<GlobalBloc>(context),
- snapshot.data.documents[index].data
- ..addEntries([
- MapEntry(
- 'activity_id',
- snapshot.data.documents[index].documentID,
- )
- ]),
- ),
- ),
- itemCount: snapshot.data.documents.length,
- ),
- );
- },
- );
- Stream<QuerySnapshot> get feedStream {
- Stream<QuerySnapshot> activities = _firestore
- .collection('activities')
- .orderBy('timestamp', descending: true)
- .snapshots();
- return activities;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement