how can I see the list of users who has liked a particular post when "X Likes" in the post is selected(like in facebook) and navigate to each user when clicked on a particular user from that list,apprciate your help
CodePudding user response:
// menuList is your userModel list with name and Like/unline(bool)
var list = menuNameList.where((element) => element == true).toList();
// this listview in the main screen // I assume you know how to build a Child widget(MyUserRow)
ListView.builder(
itemCount: list.length
itemBuilder: (context, index) =>
MyUserRow(
model: list[index],
index: index,
callback: myCallBack,
),),
// in MyUser widget you have the button or on Parent view clicked which call our callback
IconButton(
icon: Icon(Icons.search),
onPressed: () {
callback(id);
// pass your model or just id for your new screen
// or next screen directly
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondRoute(userId/UserModel())),
);
}),
for navigation to a new screen please refer navigation flutter doc
CodePudding user response:
you can make a field for like in post property
like post > field 'liked' that list has property user ID that can be navigate from other place such as news feeds,post etc