grouped_list 3.4.0
grouped_list: ^3.4.0

Flutter Android iOS web

A Flutter ListView where the list items can be grouped into sections.

Grouped list package for Flutter. #

Pub CI

A flutter ListView in which list items can be grouped to sections.

Features

  • List Items can be separated in groups.
  • For the groups an individual header can be set.
  • Almost all fields from ListView.builder available.

Getting Started #

Add the package to your pubspec.yaml:

 grouped_list: ^3.4.0

In your dart file, import the library:

import 'package:grouped_list/grouped_list.dart';

Instead of using a ListView create a GroupedListView Widget:

  GroupedListView<dynamic, String>(
    elements: _elements,
    groupBy: (element) => element['group'],
    groupSeparatorBuilder: (String groupByValue) => Text(groupByValue),
    itemBuilder: (context, dynamic element) => Text(element['name']),
    order: GroupedListOrder.ASC,
  ),

Parameters: #

NameDescriptionRequiredDefault value
elementsA list of the data you want to display in the listrequired-
groupByFunction which maps an element to its grouped valuerequired-
itemBuilder / indexedItemBuilderFunction which returns an Widget which defines the item. indexedItemBuilder provides the current index as well. If both are defined indexedItemBuilder is preferredyes, either of them-
groupSeparatorBuilder / groupHeaderBuilderFunction which returns an Widget which defines the group headers. While groupSeparatorBuilder gets the groupBy-value as parameter groupHeaderBuilder gets the whole element. If both are defined groupHeaderBuilder is preferredyes, either of them-
useStickyGroupSeparatorsWhen set to true the group header of the current visible group will stick on topnofalse
floatingHeaderWhether the sticky group header float over the list or occupy it's own spacenofalse
stickyHeaderBackgroundColorDefines the background color of the sticky header. Will only be used if useStickyGroupSeparators is usednoColor(0xffF7F7F7)
separatorA Widget which defines a separator between items inside a groupnono separator
orderChange to GroupedListOrder.DESC to reverse the group sortingnoGroupedListOrder.ASC

Also the fields from ListView.builder can be used.

Other packages : #

Check out my other package StickyGroupedList, which is based on the scrollable_positioned_list and comes with sticky headers!

173
likes
110
pub points
96%
popularity

Publisher

begnis.dev

A Flutter ListView where the list items can be grouped into sections.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on grouped_list