mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

Now we just have one TextSpan class that handles both simple strings, trees of children, and styling both. This approach simplifies the interface for most clients. This patch also removes StyledText, which was weakly typed and tricky to use correctly. The replacement is RichText, which is strongly typed and uses TextSpan.
23 lines
831 B
Dart
23 lines
831 B
Dart
// Copyright 2016 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.
|
|
|
|
// This example shows how to show the text 'Hello, world.' using the underlying
|
|
// render tree.
|
|
|
|
import 'package:flutter/rendering.dart';
|
|
|
|
void main() {
|
|
// We use RenderingFlutterBinding to attach the render tree to the window.
|
|
new RenderingFlutterBinding(
|
|
// The root of our render tree is a RenderPositionedBox, which centers its
|
|
// child both vertically and horizontally.
|
|
root: new RenderPositionedBox(
|
|
alignment: const FractionalOffset(0.5, 0.5),
|
|
// We use a RenderParagraph to display the text 'Hello, world.' without
|
|
// any explicit styling.
|
|
child: new RenderParagraph(new TextSpan(text: 'Hello, world.'))
|
|
)
|
|
);
|
|
}
|