divideTiles method

Iterable<Widget> divideTiles (
  1. {BuildContext context,
  2. @required Iterable<Widget> tiles,
  3. Color color}
)

Add a one pixel border in between each tile. If color isn't specified the ThemeData.dividerColor of the context's Theme is used.

See also:

  • Divider, which you can use to obtain this effect manually.

Implementation

static Iterable<Widget> divideTiles({ BuildContext context, @required Iterable<Widget> tiles, Color color }) sync* {
  assert(tiles != null);
  assert(color != null || context != null);

  final Iterator<Widget> iterator = tiles.iterator;
  final bool isNotEmpty = iterator.moveNext();

  final Decoration decoration = BoxDecoration(
    border: Border(
      bottom: Divider.createBorderSide(context, color: color),
    ),
  );

  Widget tile = iterator.current;
  while (iterator.moveNext()) {
    yield DecoratedBox(
      position: DecorationPosition.foreground,
      decoration: decoration,
      child: tile,
    );
    tile = iterator.current;
  }
  if (isNotEmpty)
    yield tile;
}