How can I build a DataModelBuilder inside a ListView builder and get data model of each item

Viewed 20

I have a DataModelBuilder with a list of ids, each id is them mapped to a model class. Like this:

DataModelBuilder<List<FollowsModel>>{
stream: getBloc(context).getFollowerHander.stream;
dataBuilder: (context, dataModel){
   if(success){
       return ListView.builder(
          itemCount: dataModel.data.length,
          itemBuilder: (context, index){
                 return DataModelBuilder<UserProfileModel>(
                    stream: getBloc(context).getUserProfileHandler.stream;
                     dataModel : (context, dataModel){
                            .
                            .
                            .
                   }  
                 )
             
           } 
     );
   }
   }
}

Now the problem is I am getting two list tiles which is exactly the number of users following, but the username is for one user. I want the name of each user to appear separately on each tile.

1 Answers

I think you should bring all the information you need inside the first DataModelBuild<List>, make the FollowsModel a superset of UserProfileModel and inside of getFollowerHander join this two datas. Or turn the nested DataModelBuilder into a FutureBuilder.

Related