grouped_list 2.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 96

Grouped list package for Flutter #

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


  • All fields from ListView.builder constructor available.
  • List Items can be separated in groups.
  • For the groups an individual header can be set.
  • Sticky Headers. Option to stick top header at the top.
  • Option to sort the groups.

Getting Started #

Add the package to your pubspec.yaml:

 grouped_list: ^2.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:

    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.

Required Parameters:

  • elements: A list of the data you want to display in the list.
  • groupBy: Function which maps an element to its grouped value.
  • itemBuilder: Function which returns an Widget which defines the item.
  • groupSeparator: Function which returns an Widget which defines the section separator.
Widget _buildGroupSeparator(dynamic groupByValue) {
  return Text('$groupByValue');

The parameter groupByValue has the return type of the defined groupBy function.

Optional Parameters:

  • useStickyGroupSeparators. If set to true the top groupSeparator will stick on top. Default is false.
  • order: By default it's GroupedListOrder.ASC. Change to GroupedListOrder.DESC for reversing the group sorting.
  • separator: A Widget which defines a separator between items inside a section.
  • sort: A bool which defines if the passed data should be sorted by the widget. By default it's 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.
  • The elements need to be sorted according to the groupBy return value. The Widgets sorts the elements by default. Disable the sorting only if your list is sorted beforehand.

[1.0.0] - 13.08.2019 #

  • Initial release

[1.1.0] - 14.08.2019 #

  • Added example
  • Edited readme and package description

[1.2.0] - 15.08.2019 #

  • Widget sort the list elements now according the groupByvalue. Can be switched off through the parameter sort

[1.2.1] - 18.08.2019 #

  • Improved documentary

[1.3.0] - 10.03.2020 #

  • Add order option to the widget. With this the sorting of the groups can be reversed.

[1.3.1] - 12.03.2020 #

  • Bugfix: The order option also works for groups which aren't comparable.

[2.0.0] - 18.03.2020 #

  • New Feature: Sticky Headers! ** To use the sticky header set useStickyGroupSeparators to true. ** The parameter elements is now required.
  • Due to potential beaking changes the feature comes with a new major release.

[2.0.1] - 28.03.2020 #

  • Bugfix: If no separator was specified a divider was rendered.
  • Bugfix: Adding items dynamically to an existing group led to a new group to be created.

[2.0.2] - 28.03.2020 #

  • Documentation

[2.1.0] - 28.03.2020 #

  • Fixed bug where wrong headers are displayed while using sticky headers.


import 'package:flutter/material.dart';
import 'package:grouped_list/grouped_list.dart';

void main() => runApp(MyApp());

List _elements = [
  {'name': 'John', 'group': 'Team A'},
  {'name': 'Will', 'group': 'Team B'},
  {'name': 'Beth', 'group': 'Team A'},
  {'name': 'Miranda', 'group': 'Team B'},
  {'name': 'Mike', 'group': 'Team C'},
  {'name': 'Danny', 'group': 'Team C'},

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      theme: ThemeData(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Grouped List View Example'),
        body: GroupedListView<dynamic, String>(
          groupBy: (element) => element['group'],
          elements: _elements,
          order: GroupedListOrder.DESC,
          useStickyGroupSeparators: true,
          groupSeparatorBuilder: (String value) => Padding(
            padding: const EdgeInsets.all(8.0),
            child: Center(
                child: Text(
              style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
          itemBuilder: (c, element) {
            return Card(
              elevation: 8.0,
              margin: new EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),
              child: Container(
                child: ListTile(
                      EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
                  leading: Icon(Icons.account_circle),
                  title: Text(element['name']),
                  trailing: Icon(Icons.arrow_forward),

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  grouped_list: ^2.1.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:grouped_list/grouped_list.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Apr 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies