Generalize grid layout

This patch make grid layout much more flexible. The behavior is factored
out into a GridDelegate that's modeled after the custom layout
delegates. The patch includes a MaxTileWidthGridDelegate that implements
the old behavior and a FixedColumnCountGridDelegate that implements a
grid layout with a fixed number of columns.

Fixes #1048
This commit is contained in:
Adam Barth
2016-01-02 02:20:10 -08:00
parent a5925149d6
commit 46a178dce6
7 changed files with 478 additions and 91 deletions

View File

@@ -20,7 +20,10 @@ Color randomColor() {
RenderBox buildGridExample() {
List<RenderBox> children = new List<RenderBox>.generate(30, (_) => new RenderSolidColorBox(randomColor()));
return new RenderGrid(children: children, maxChildExtent: 100.0);
return new RenderGrid(
children: children,
delegate: new MaxTileWidthGridDelegate(maxTileWidth: 100.0)
);
}
main() => new RenderingFlutterBinding(root: buildGridExample());