hello_world.dart 1.09 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6 7
// This example shows how to show the text 'Hello, world.' using the underlying
// render tree.

8 9 10
import 'package:flutter/rendering.dart';

void main() {
11
  // We use RenderingFlutterBinding to attach the render tree to the window.
12
  RenderingFlutterBinding(
13 14
    // The root of our render tree is a RenderPositionedBox, which centers its
    // child both vertically and horizontally.
15
    root: RenderPositionedBox(
16
      // We use a RenderParagraph to display the text 'Hello, world.' without
17
      // any explicit styling.
18
      child: RenderParagraph(
Ian Hickson's avatar
Ian Hickson committed
19 20 21 22 23 24 25
        const TextSpan(text: 'Hello, world.'),
        // The text is in English so we specify the text direction as
        // left-to-right. If the text had been in Hebrew or Arabic, we would
        // have specified right-to-left. The Flutter framework does not assume a
        // particular text direction.
        textDirection: TextDirection.ltr,
      ),
26
    ),
27
  ).scheduleFrame();
28
}