flutter/examples/rendering/render_grid.dart
Hixie a6c473ea95 Strong modeify the examples
This makes skyanalyzer also check the examples, and fixes everything it
found there.
2015-10-23 18:13:25 -07:00

27 lines
824 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:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'lib/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<RenderBox>.generate(30, (_) => new RenderSolidColorBox(randomColor()));
return new RenderGrid(children: children, maxChildExtent: 100.0);
}
main() => new FlutterBinding(root: buildGridExample());