grouped_listview 0.0.2 copy "grouped_listview: ^0.0.2" to clipboard
grouped_listview: ^0.0.2 copied to clipboard

Simple Flutter widget to display grouped ListView

GroupedListView #

This is a simple flutter widget to easily created grouped lists.

Sample #

For Usage, create a GroupedListView like the following

class Group {
    String groupName;
    int value;

    Group(this.groupName, this.value);
}

class ExampleWidget extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return GroupedListView<Group, String>(
                   collection: [Group("Test1", 1), Group("Test2", 2), Group("Test1", 3),],
                   groupBy: (Group g) => g.groupName,
                   listBuilder: (BuildContext context, Group g) => ListTile(title: Text(g.value.toString())),
                   groupBuilder: (BuildContext context, String name) => Text(name),
           );
  }
}

Options #

GroupedListView is a generic widget. It has two generic options:

  • First one is TElement, which is the type of the list
  • Second one is TGroup, which is the type of the grouping attribute

GroupedListView has four required parameters:

  • collection: List to display. Must be of type TElement
  • groupBy: Function, which returns the field to group by. Parameter is of type TGroup, return value is of type TElement
  • listBuilder: Function, which creates the widget for the list element. Parameters are BuildContext and the Element of type TElement to display.
  • groupBuilder: Function, to create the widget for the group headers. Parameters are BuildContext and the Value of type TGroup to display.
5
likes
10
pub points
46%
popularity

Publisher

unverified uploader

Simple Flutter widget to display grouped ListView

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on grouped_listview