GroupedListView

This is a simple flutter widget to easily created grouped lists.

Sample

For Usage, create a GroupedListView like the following

class Group {
    String groupName;
    int value;

    Group(this.groupName, this.value);
}

class ExampleWidget extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return GroupedListView<Group, String>(
                   collection: [Group("Test1", 1), Group("Test2", 2), Group("Test1", 3),],
                   groupBy: (Group g) => g.groupName,
                   listBuilder: (BuildContext context, Group g) => ListTile(title: Text(g.value.toString())),
                   groupBuilder: (BuildContext context, String name) => Text(name),
           );
  }
}

Options

GroupedListView is a generic widget. It has two generic options:

  • First one is TElement, which is the type of the list
  • Second one is TGroup, which is the type of the grouping attribute

GroupedListView has four required parameters:

  • collection: List to display. Must be of type TElement
  • groupBy: Function, which returns the field to group by. Parameter is of type TGroup, return value is of type TElement
  • listBuilder: Function, which creates the widget for the list element. Parameters are BuildContext and the Element of type TElement to display.
  • groupBuilder: Function, to create the widget for the group headers. Parameters are BuildContext and the Value of type TGroup to display.

Libraries

grouped_listview

Dart

dart:ui
Built-in types and core primitives for a Flutter application. [...]

Core

dart:async
Support for asynchronous programming, with classes such as Future and Stream. [...]
dart:collection
Classes and utilities that supplement the collection support in dart:core. [...]
dart:convert
Encoders and decoders for converting between different data representations, including JSON and UTF-8. [...]
dart:core
Built-in types, collections, and other core functionality for every Dart program. [...]
dart:developer
Interact with developer tools such as the debugger and inspector. [...]
dart:math
Mathematical constants and functions, plus a random number generator. [...]
dart:typed_data
Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers) and SIMD numeric types. [...]

VM

dart:io
File, socket, HTTP, and other I/O support for non-web applications. [...]
dart:isolate
Concurrent programming using isolates: independent workers that are similar to threads but don't share memory, communicating only via messages. [...]