Sticky grouped list package for Flutter.

Pub CI

A ListView with sticky headers in which list items can be grouped to sections. Based on scrollable_positioned_list.

Features

  • Features from scrollable_positioned_list.
  • List items can be separated in groups.
  • For the groups an individual header can be set.
  • Sticky headers with floating option.
  • All fields from ScrollablePositionedList available.

Getting Started

Add the package to your pubspec.yaml:

 sticky_ grouped_list: ^0.2.0

In your dart file, import the library:

import 'package:sticky_grouped_list/sticky_grouped_list.dart';

Create a StickyGroupedListView Widget:

  StickyGroupedListView<dynamic, String>(
    elements: _elements,
    groupBy: (dynamic element) => element['group'],
    groupSeparatorBuilder: (dynamic element) => Text(element['group']),
    itemBuilder: (context, dynamic element) => Text(element['name']),
    order: StickyGroupedListOrder.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-
floatingHeaderWhen set to true the sticky header will float over the listnofalse
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-
groupSeparatorBuilderFunction which gets a element and returns an Widget which defines the group header separatorrequired-
separatorA Widget which defines a separator between items inside a groupnono separator
orderChange to StickyGroupedListOrder.DESC to reverse the group sortingnoStickyGroupedListOrder.ASC

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

Used packages:

Package nameCopyrightLicense
scrollable_positioned_listCopyright 2018 the Dart project authors, Inc. All rights reservedBSD 3-Clause "New" or "Revised" License

Libraries

sticky_grouped_list