cupertino_listview 1.0.5
cupertino_listview: ^1.0.5 copied to clipboard

Flutter Android iOS Linux macOS web Windows

Display a vertical list of sections (group of items), respecting iOS UX design, where the current section title remains displayed on top (until the next one push it away).

cupertino_listview - Display a vertical list of sections (group of items), respecting iOS UX design. #

This library tends to be the equivalent of iOS UITableView with plain sections.

It contains one widget: CupertinoListView, that mimics in its usage the [ListView] widget.

Therefore ou have two ways to build it:

  • "dynamic" build of children, using [CupertinoListView.builder].
  • "static" children, using [CupertinoListView] constructor.

Examples #

CupertinoListView.builder(
    sectionCount: _data.length,
    itemInSectionCount: (section) => _data[section].items.length,
    sectionBuilder: (context, sectionPath, _) => Text(_data[sectionPath.section].name),
    childBuilder: (context, indexPath) => Text(_data[indexPath.section].items[indexPath.child]),
    separatorBuilder: (context, indexPath) => Divider(indent: 20.0),
    controller: _scrollController,
);
CupertinoListView(
    children: _data.fold([], (list, section) {
        return [
          Text(_data[section].name),
          ..._data[section].items.map((item) => Text(item)).toList(),
        ];
    }),
    padding: const EdgeInsets.all(4.0),
);

another example #

You can also use this library in combination to scroll_to_index.

The complete explanation is available here: https://medium.com/flutter-community/flutter-ios-styled-listview-cc21d8574dd5

CupertinoListView properties #

ParameterDescriptionDefault value
childrenList of sections. A section is a list with the section title as its first element, followed by section's items.-
floatingSectionBuilderOptional builder used to create floating section widget. This builder is intended to differentiate the section widget from list and the floating one.-
sectionCountNumber of sections.-
itemInSectionCountRetrieve the number of items of sections.-
sectionBuilderUsed to build the section title.-
childBuilderUsed to build an item of a section.-
separatorBuilderUsed to build separator between two children of sections.-
controllerControl the position to which this scroll view is scrolled.-
cacheExtentCache elements used to display faster and smoother the list.-
clipBehaviorSame as [ListView].clipBehavior: "ways to clip a widget's content".Clip.hardEdge
dragStartBehaviorSame as [ListView].dragStartBehavior: "Determines the way that drag start behavior is handled".DragStartBehavior.start
physicsSame as [ListView].physics: "How the scroll view should respond to user input".-
restorationIdSame as [ListView].restorationId: used "to save and restore the scroll offset of the scrollable".-
paddingThe amount of space by which to inset the children.-
keyboardDismissBehaviorDefines how the list will dismiss the keyboard automatically.manual
20
likes
110
pub points
55%
popularity

Publisher

davidgonzalez-freelance.fr

Display a vertical list of sections (group of items), respecting iOS UX design, where the current section title remains displayed on top (until the next one push it away).

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on cupertino_listview