blob: 1f49ca71c4bddfb1e60599a3b10da08ec89612d0 [file] [log] [blame]
Adam Barth948ae152016-02-13 00:52:56 -08001// 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 Barth025c43d2016-02-13 14:30:37 -08005// This example shows how to show the text 'Hello, world.' using the underlying
6// render tree.
7
Adam Barth948ae152016-02-13 00:52:56 -08008import 'package:flutter/rendering.dart';
9
10void main() {
Adam Barth025c43d2016-02-13 14:30:37 -080011 // We use RenderingFlutterBinding to attach the render tree to the window.
Alexandre Ardhuind927c932018-09-12 08:29:29 +020012 RenderingFlutterBinding(
Adam Barth025c43d2016-02-13 14:30:37 -080013 // The root of our render tree is a RenderPositionedBox, which centers its
14 // child both vertically and horizontally.
Alexandre Ardhuind927c932018-09-12 08:29:29 +020015 root: RenderPositionedBox(
Adam Barth0044ea22017-10-02 00:06:24 -070016 alignment: Alignment.center,
Adam Barth1ab3d3a2016-02-13 16:48:15 -080017 // We use a RenderParagraph to display the text 'Hello, world.' without
Adam Barth025c43d2016-02-13 14:30:37 -080018 // any explicit styling.
Alexandre Ardhuind927c932018-09-12 08:29:29 +020019 child: RenderParagraph(
Ian Hicksonca7d2d22017-09-07 16:57:38 -070020 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 Barth948ae152016-02-13 00:52:56 -080027 )
28 );
29}