grouped_list 3.1.0 copy "grouped_list: ^3.1.0" to clipboard
grouped_list: ^3.1.0 copied to clipboard

outdated

A ListView where list items can be grouped into sections. With sticky headers.

Grouped list package for Flutter. With sticky Headers #

A List with Sticky Headers! Basically 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.
  • Sticky Headers. With Floating Option.
  • Almost all fields from ListView.builder constructor available.

Getting Started #

Add the package to your pubspec.yaml:

grouped_list: ^3.1.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(
   elements: _elements,
   groupBy: (element) => element['group'],
   groupSeparatorBuilder: _buildGroupSeparator,
   itemBuilder: (context, element) => Text(element['name']),
   order: GroupedListOrder.ASC,
 ),

You can also use most fields from the ListView.builder constructor.

Parameters: #

  • elements: A list of the data you want to display in the list (required).
  • groupBy: Function which maps an element to its grouped value (required).
  • itemBuilder or indexedItemBuilder: Function which returns an Widget which defines the item. indexedItemBuilder provides the current index as well. If both are defined indexedItemBuilder is preferred.
  • groupSeparator: Function which returns an Widget which defines the section separator (required).
  Widget _buildGroupSeparator(dynamic groupByValue) {
  return Text('$groupByValue');
  }
  • separator: A Widget which defines a separator between items inside a section.
  • order: By default it's GroupedListOrder.ASC. Change to GroupedListOrder.DESC for reversing the group sorting.
  • useStickyGroupSeparators. If set to true the top groupSeparator will stick on top. Default is true.

New Feature: #

  • Sticky Headers can now float above the list. Just set the option floatingHeader to true.
Notice:
  • The item builder functions only creates the actual list items. For seperator items use the separator parameter.
  • Other than the itemBuilder function of the ListView.builder constructor the function provides the specific element instead of the index as parameter.
1485
likes
0
pub points
99%
popularity

Publisher

verified publisherbegnis.dev

A ListView where list items can be grouped into sections. With sticky headers.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on grouped_list