align_items.dart 2.24 KB
Newer Older
1 2 3 4
// 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.

5
import 'package:flutter/rendering.dart';
6

7
import 'lib/solid_color_box.dart';
8 9

void main() {
Hixie's avatar
Hixie committed
10
  RenderFlex table = new RenderFlex(direction: FlexDirection.vertical);
11

Hixie's avatar
Hixie committed
12
  for (FlexAlignItems alignItems in FlexAlignItems.values) {
13
    TextStyle style = const TextStyle(color: const Color(0xFF000000));
Hixie's avatar
Hixie committed
14
    RenderParagraph paragraph = new RenderParagraph(new StyledTextSpan(style, <TextSpan>[new PlainTextSpan("$alignItems")]));
15
    table.add(new RenderPadding(child: paragraph, padding: new EdgeDims.only(top: 20.0)));
Hixie's avatar
Hixie committed
16
    RenderFlex row = new RenderFlex(alignItems: alignItems, textBaseline: TextBaseline.alphabetic);
17 18
    style = new TextStyle(fontSize: 15.0, color: const Color(0xFF000000));
    row.add(new RenderDecoratedBox(
Collin Jackson's avatar
Collin Jackson committed
19
      decoration: new BoxDecoration(backgroundColor: const Color(0x7FFFCCCC)),
Hixie's avatar
Hixie committed
20
      child: new RenderParagraph(new StyledTextSpan(style, <TextSpan>[new PlainTextSpan('foo foo foo')]))
21 22 23
    ));
    style = new TextStyle(fontSize: 10.0, color: const Color(0xFF000000));
    row.add(new RenderDecoratedBox(
Collin Jackson's avatar
Collin Jackson committed
24
      decoration: new BoxDecoration(backgroundColor: const Color(0x7FCCFFCC)),
Hixie's avatar
Hixie committed
25
      child: new RenderParagraph(new StyledTextSpan(style, <TextSpan>[new PlainTextSpan('foo foo foo')]))
26
    ));
Hixie's avatar
Hixie committed
27
    RenderFlex subrow = new RenderFlex(alignItems: alignItems, textBaseline: TextBaseline.alphabetic);
28
    style = new TextStyle(fontSize: 25.0, color: const Color(0xFF000000));
Collin Jackson's avatar
Collin Jackson committed
29 30
    subrow.add(new RenderDecoratedBox(
      decoration: new BoxDecoration(backgroundColor: const Color(0x7FCCCCFF)),
Hixie's avatar
Hixie committed
31
      child: new RenderParagraph(new StyledTextSpan(style, <TextSpan>[new PlainTextSpan('foo foo foo foo')]))
32
    ));
Collin Jackson's avatar
Collin Jackson committed
33 34
    subrow.add(new RenderSolidColorBox(const Color(0x7FCCFFFF), desiredSize: new Size(30.0, 40.0)));
    row.add(subrow);
35
    table.add(row);
Hixie's avatar
Hixie committed
36 37
    final FlexParentData rowParentData = row.parentData;
    rowParentData.flex = 1;
38 39 40 41 42 43 44
  }

  RenderDecoratedBox root = new RenderDecoratedBox(
    decoration: new BoxDecoration(backgroundColor: const Color(0xFFFFFFFF)),
    child: new RenderPadding(child: table, padding: new EdgeDims.symmetric(vertical: 50.0))
  );

45
  new FlutterBinding(root: root);
46
}