CupertinoListView constructor

CupertinoListView({
  1. required List<List<Widget>> children,
  2. ScrollController? controller,
  3. double? cacheExtent,
  4. Clip clipBehavior = Clip.hardEdge,
  5. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  6. ScrollPhysics? physics,
  7. String? restorationId,
  8. EdgeInsets? padding,
  9. ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
  10. required SectionBuilder floatingSectionBuilder,
})

Creates a scrollable, linear array of widgets from an explicit List of sections. Each section is a list containing the section title widget, as first element, followed by its children.

The floating section title is built using floatingSectionBuilder widget builder, or through the list of children. It's intended to differentiate the section widget inside the Scrollable list from the floating section widget.

This constructor is appropriate for list views with a small number of children because constructing the List requires doing work for every child that could possibly be displayed in the list view instead of just those children that are actually visible.

Implementation

factory CupertinoListView({
  required List<List<Widget>> children,
  ScrollController? controller,
  double? cacheExtent,
  Clip clipBehavior = Clip.hardEdge,
  DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  ScrollPhysics? physics,
  String? restorationId,
  EdgeInsets? padding,
  ScrollViewKeyboardDismissBehavior keyboardDismissBehavior =
      ScrollViewKeyboardDismissBehavior.manual,
  required SectionBuilder floatingSectionBuilder,
}) {
  assert(children.isNotEmpty);
  children.forEach((section) {
    assert(section.length > 1);
  });

  final delegate = CupertinoChildListDelegate(
    children: children,
    floatingSectionBuilder: floatingSectionBuilder,
  );
  return CupertinoListView._(
    delegate: delegate,
    controller: controller,
    restorationId: restorationId,
    physics: physics,
    keyboardDismissBehavior: keyboardDismissBehavior,
    dragStartBehavior: dragStartBehavior,
    clipBehavior: clipBehavior,
    cacheExtent: cacheExtent,
    padding: padding,
  );
}