flutter/examples/rendering/render_grid.dart
Eric Seidel b122969624 Add support for RenderGrid
I'll write the Widget wrapper in the next CL, including adding
support for padding at the Widget layer.

@Hixie
2015-08-26 13:52:30 -07:00

26 lines
810 B
Dart

// Copyright 2015 The Chromium 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 'dart:math' as math;
import 'package:sky/rendering.dart';
import 'package:sky/theme/colors.dart' as colors;
import 'solid_color_box.dart';
Color randomColor() {
final List<Color> allColors = [
colors.Blue,
colors.Indigo
].map((p) => p.values).fold([], (a, b) => a..addAll(b));
final random = new math.Random();
return allColors[random.nextInt(allColors.length)];
}
RenderBox buildGridExample() {
List<RenderBox> children = new List.generate(30, (_) => new RenderSolidColorBox(randomColor()));
return new RenderGrid(children: children, maxChildExtent: 100.0);
}
main() => new SkyBinding(root: buildGridExample());