synw / sqlcool

Easy and reactive Sqlite for Flutter
MIT License
163 stars 28 forks source link

Nested StreamBuilder not working #30

Open saket1999 opened 4 years ago

saket1999 commented 4 years ago

When I am using two streambuilder of SelectBloc one inside another. The inner stream builder is not working. The inner stream builder is always returning text widget.

StreamBuilder<List<Map>>(
                stream: filterBloc.items,
                builder: (BuildContext context, AsyncSnapshot filterSnapshot) {
                  if(filterSnapshot.hasData) {
                    if(filterSnapshot.data.length==0) {
                      return Center(
                        child: Text('Downloading Data'),
                      );
                    }
                    Map<String, int> filterMap = Map<String, int>();
                    for(int i=0; i<filterSnapshot.data.length; i++)
                      filterMap[filterSnapshot.data[i]['name']] = filterSnapshot.data[i]['enabled'];
                    return StreamBuilder<List<Map>>(
                      stream: modelBloc.items,
                      builder: (BuildContext context, AsyncSnapshot snapshot) {
                        if(snapshot.hasData) {
                          if(snapshot.data.length==0) {
                            return Center(
                              child: Text('Downloading Data'),
                            );
                          }
                          return ListView.builder(
                            shrinkWrap: true,
                            itemCount: snapshot.data.length,
                            itemBuilder: (context, index) {
                              Model item = Model().fromDb(snapshot.data[index]);
                              return ContestCard(size: size, item: item);
                            },
                          );
                        }
                        return Text('Loading');
                      },
                    );
                  }
                  return Container();
                },
              ),