搜尋套件、儲存庫與 APP 分類

GitHub 儲存庫Dimibe/grouped_list

分組列表

一個 Flutter ListView,其中項目可以分組為區段。

分組列表 專案封面
星標
416
分支
108
最近推送(UTC)
2025年11月21日
專案狀態
未封存

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

Grouped list package for Flutter.

pub package package publisher build

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

Features
  • Sound null safety support!
  • Easy creation of chat dialog.
  • 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: ^6.0.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']),
   itemComparator: (item1, item2) => item1['name'].compareTo(item2['name']), // optional
   useStickyGroupSeparators: true, // optional
   floatingHeader: true, // optional
   order: GroupedListOrder.ASC, // optional
   footer: Text("Widget at the bottom of list"), // optional
 ),
Parameters:
Name Description Required Default value
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 / indexedItemBuilder / interdependentItemBuilder / grouItemBuilder Function which returns an Widget which defines the item.
* indexedItemBuilder provides the current index as well.
* interdependentItemBuilder provides the previous and next items as well.
* groupItemBuilder provides information if the item is the first or last element inside a group.
indexedItemBuilder is preferred over interdependentItemBuilder and interdependentItemBuilder is preferred overitemBuilder.
yes, either of them -
groupSeparatorBuilder / groupHeaderBuilder Function which returns a 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 preferred yes, either of them -
groupStickyHeaderBuilder Function which returns a Widget which defines the sticky group header, when useStickyGroupSeparators is true. If not defined groupSeparatorBuilder or groupHeaderBuilder will be used as described above. no -
useStickyGroupSeparators When set to true the group header of the current visible group will stick on top no false
floatingHeader Whether the sticky group header float over the list or occupy it's own space no false
stickyHeaderBackgroundColor Defines the background color of the sticky header. Will only be used if useStickyGroupSeparators is used no Color(0xffF7F7F7)
separator A Widget which defines a separator between items inside a group no no separator
groupComparator Can be used to define a custom sorting for the groups. Otherwise the natural sorting order is used no -
itemComparator Can be used to define a custom sorting for the elements inside each group. Otherwise the natural sorting order is used no -
order Change to GroupedListOrder.DESC to reverse the group sorting no GroupedListOrder.ASC
footer Widget at the bottom of the list no -

Also the fields from ListView.builder can be used.

Highlight - SilverGroupedList

Now supporting a grouped list based on a silver list. Just use SilverGroupedListView instead of GroupedListView. An example can be found under example/lib/example_silver. Note that some options of the GroupedListView are currently not available in SilverGroupedListView.

Highlight - Chat Dialog

Easy creation of chat dialogs. Just set the option reverse to true and order to GroupedListOrder.DESC. A full example can be found in the examples. The list will be scrolled to the end in the initial state and therefore scrolling will be against redeaing direction.

My other packages :

For easy creation of chat-like dialogs:

Check out my other package StickyGroupedList, which is based on the scrollable_positioned_list.

Dimitrios Begnis GitHub avatar
GitHub 作者

Dimitrios Begnis ↗

Aachen, Germany
語言DartCMakeSwiftShellCC++KotlinObjective-C

分類

此儲存庫發佈的套件

使用的依賴

依賴清單 3 項

  • flutter{"sdk":"flutter"}
  • flutter_test開發依賴{"sdk":"flutter"}
  • flutter_lints開發依賴>=2.0.3 <7.0.0

如何選擇適合專案的儲存庫?

先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。

  1. 透過儲存庫名稱、作者或描述搜尋,再依技術分類縮小範圍。
  2. 綜合星標、分支與最近推送比較專案;星標反映社群關注,不保證品質。
  3. 使用前在 GitHub 確認 README、授權條款與 Issues。

來源與維護

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗