Adam Barth | 948ae15 | 2016-02-13 00:52:56 -0800 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Adam Barth | 025c43d | 2016-02-13 14:30:37 -0800 | [diff] [blame] | 5 | // This example shows how to show the text 'Hello, world.' using the underlying |
| 6 | // render tree. |
| 7 | |
Adam Barth | 948ae15 | 2016-02-13 00:52:56 -0800 | [diff] [blame] | 8 | import 'package:flutter/rendering.dart'; |
| 9 | |
| 10 | void main() { |
Adam Barth | 025c43d | 2016-02-13 14:30:37 -0800 | [diff] [blame] | 11 | // We use RenderingFlutterBinding to attach the render tree to the window. |
Alexandre Ardhuin | d927c93 | 2018-09-12 08:29:29 +0200 | [diff] [blame] | 12 | RenderingFlutterBinding( |
Adam Barth | 025c43d | 2016-02-13 14:30:37 -0800 | [diff] [blame] | 13 | // The root of our render tree is a RenderPositionedBox, which centers its |
| 14 | // child both vertically and horizontally. |
Alexandre Ardhuin | d927c93 | 2018-09-12 08:29:29 +0200 | [diff] [blame] | 15 | root: RenderPositionedBox( |
Adam Barth | 0044ea2 | 2017-10-02 00:06:24 -0700 | [diff] [blame] | 16 | alignment: Alignment.center, |
Adam Barth | 1ab3d3a | 2016-02-13 16:48:15 -0800 | [diff] [blame] | 17 | // We use a RenderParagraph to display the text 'Hello, world.' without |
Adam Barth | 025c43d | 2016-02-13 14:30:37 -0800 | [diff] [blame] | 18 | // any explicit styling. |
Alexandre Ardhuin | d927c93 | 2018-09-12 08:29:29 +0200 | [diff] [blame] | 19 | child: RenderParagraph( |
Ian Hickson | ca7d2d2 | 2017-09-07 16:57:38 -0700 | [diff] [blame] | 20 | const TextSpan(text: 'Hello, world.'), |
| 21 | // The text is in English so we specify the text direction as |
| 22 | // left-to-right. If the text had been in Hebrew or Arabic, we would |
| 23 | // have specified right-to-left. The Flutter framework does not assume a |
| 24 | // particular text direction. |
| 25 | textDirection: TextDirection.ltr, |
| 26 | ), |
Adam Barth | 948ae15 | 2016-02-13 00:52:56 -0800 | [diff] [blame] | 27 | ) |
| 28 | ); |
| 29 | } |