CupertinoListSection.insetGrouped constructor Null safety

const CupertinoListSection.insetGrouped(
  1. {Key? key,
  2. List<Widget>? children,
  3. Widget? header,
  4. Widget? footer,
  5. EdgeInsetsGeometry? margin,
  6. Color backgroundColor = CupertinoColors.systemGroupedBackground,
  7. BoxDecoration? decoration,
  8. Clip clipBehavior = Clip.hardEdge,
  9. double dividerMargin = _kInsetDividerMargin,
  10. double? additionalDividerMargin,
  11. double? topMargin,
  12. bool hasLeading = true}
)

Creates a section that mimicks standard "Inset Grouped" iOS list section.

The CupertinoListSection.insetGrouped constructor creates a round-edged and padded section that is seen in iOS Notes and Reminders apps. It creates an iOS-style header, and the dividers between rows. Does not create borders on top and bottom of the rows.

The header parameter sets the form section header. The section header lies above the children rows, with margins that match the iOS style.

The footer parameter sets the form section footer. The section footer lies below the children rows.

The children parameter is required and sets the list of rows shown in the section. The children parameter takes a list, as opposed to a more efficient builder function that lazy builds, because forms are intended to be short in row count. It is recommended that only CupertinoListTile widget be included in the children list in order to retain the iOS look.

The margin parameter sets the spacing around the content area of the section encapsulating children, and defaults to the standard notched-style iOS form padding.

The decoration parameter sets the decoration around children. If null, defaults to CupertinoColors.secondarySystemGroupedBackground. If null, defaults to 10.0 circular radius when constructing with CupertinoListSection.insetGrouped. Defaults to zero radius for the standard CupertinoListSection constructor.

The backgroundColor parameter sets the background color behind the section. If null, defaults to CupertinoColors.systemGroupedBackground.

The dividerMargin parameter sets the starting offset of the divider between rows.

The additionalDividerMargin parameter adds additional margin to existing dividerMargin when hasLeading is set to true. By default, it offsets for the width of leading and space between leading and title of CupertinoListTile, but it can be overwritten for custom look.

The hasLeading parameter specifies whether children CupertinoListTile widgets contain leading or not. Used for calculating correct starting margin for the divider between rows.

The content will be clipped (or not) according to this option.

See the enum Clip for details of all possible options and their common use cases.

Implementation

const CupertinoListSection.insetGrouped({
  super.key,
  this.children,
  this.header,
  this.footer,
  EdgeInsetsGeometry? margin,
  this.backgroundColor = CupertinoColors.systemGroupedBackground,
  this.decoration,
  this.clipBehavior = Clip.hardEdge,
  this.dividerMargin = _kInsetDividerMargin,
  double? additionalDividerMargin,
  this.topMargin,
  bool hasLeading = true,
}) : assert((children != null && children.length > 0) || header != null),
     type = CupertinoListSectionType.insetGrouped,
     additionalDividerMargin = additionalDividerMargin ??
         (hasLeading
             ? _kInsetAdditionalDividerMargin
             : _kInsetAdditionalDividerMarginWithoutLeading),
     margin = margin ?? (header == null ? _kDefaultInsetGroupedRowsMargin : _kDefaultInsetGroupedRowsMarginWithHeader);