How to group list inside another group list.
usernamekk opened this issue · 4 comments
@usernamekk Please describe what you want to do, what you have tried so far an what is not working.
I have a custom object and also json decoder in my code. In my object, I have fields like name,lga,townOfOrigin etc. I have grouped these people into lga(Local Government Area of origin) group but inside the lga group, want to group their townOfOrigin also, then names of people.
class People {
final String id;
final String title;
final String name;
final String location;
final String lga;
final String Office;
final String townOfOrigin;
final String phone;
final String email;
final String imageUrl;
bool isExpanded;
)
StickyGroupedListView<People, String>(
elements: Users,
groupBy: (element) => element.lga,
groupSeparatorBuilder: (filteredUsers) => Text(filteredUsers.lga),
itemBuilder: (ctx, filteredUsers) => Text(filteredUsers.townOfOrigin)..........expanded.... Text(filteredUsers.name)
Sample of what I was able to get from your StickyGroupedListView here
lga => townOfOrigin => names
I hope you will understand. Thanks
Waiting for your reply.
@usernamekk The way you are trying to archive that will not work because itemBuilder
has only individual people.
A solution which might work will need to look like the following:
- Group your people accoring thier
lga
before hand. Users
will then be aList<List<People>>
instead ofList<People>
- Change
StickyGroupedListView<People, String>
toStickyGroupedListView<List<People>, String>
groupBy
can be grouped by the lga of any of thePeople
inside each List because they all should have the samelga
.itemBuilder
will then get aList<People>
which can be again used for anotherStickyGroupedListView
which is grouped bytownOfOrigin
.
One remark: I did not test this and do not know if this will work. I'm closing the issue because this is not an issue of this package but more an implementation question.