12345678910111213141516171819202122232425262728293031323334 |
- // Copyright 2014 The Flutter Authors. All rights reserved.
- // Use of this source code is governed by a BSD-style license that can be
- // found in the LICENSE file.
- import 'package:flutter/material.dart';
- Iterable<Widget> divideTiles({BuildContext context, @required Iterable<Widget> tiles, Color color, includeLast = false}) 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 includeLast ? DecoratedBox(
- position: DecorationPosition.foreground,
- decoration: decoration,
- child: tile,
- ) : tile;
- }
|