divideTiles static method
Iterable<Widget>
divideTiles({
- BuildContext? context,
- required Iterable<
Widget> tiles, - 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:
- VerticalDivider, which you can use to obtain this effect manually.
Implementation
static Iterable<Widget> divideTiles(
{BuildContext? context,
required Iterable<Widget> tiles,
Color? color}) sync* {
assert(color != null || context != null);
final Iterator<Widget> iterator = tiles.iterator;
final bool hasNext = iterator.moveNext();
if (!hasNext) return;
final Decoration decoration = BoxDecoration(
border: Border(
right: 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 (hasNext) yield tile;
}