gap method

List<Widget> gap(
  1. double spacing, {
  2. double? crossAxisExtent,
  3. Color? color,
})

Returns a widget list with Gap between each widget.

Inserts a Gap of the specified spacing between each widget in the list.

The spacing parameter defines the size of the gap between widgets. It must be non-null and positive.

The optional crossAxisExtent parameter allows you to specify the gap size along the cross axis (e.g., width of gap in a Column).

The optional color parameter is useful for debugging to visualize where gaps are placed.

Example:

Column(
  children: [
    Text('First item'),
    Text('Second item'),
    Text('Third item'),
  ].gap(16),
)

See also:

  • Gap, which creates a fixed-size gap.
  • sliverGap, for adding gaps between slivers.

Implementation

List<Widget> gap(double spacing, {double? crossAxisExtent, Color? color}) => _gapExtBuildWith(
      Gap(
        spacing,
        crossAxisExtent: crossAxisExtent,
        color: color,
      ),
    );