Flutter Widget之Text

Widget:https://flutter.io/docs/development/ui/widgets
Text:https://docs.flutter.io/flutter/widgets/Text-class.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import 'package:flutter/material.dart';

class TextDemoPage extends StatefulWidget {
@override
State<StatefulWidget> createState() => new _TextDemoPageState();
}

class _TextDemoPageState extends State<TextDemoPage> {
String _name = 'Joe.Ye';

@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text('Text Page Demo'),),
body: Center(
child: Column(
children: <Widget>[
Text(
'Hello, $_name! How are you?',
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontWeight: FontWeight.bold),
),
const Text.rich(
TextSpan(
text: 'Hello', // default text style
children: <TextSpan>[
TextSpan(text: ' beautiful ', style: TextStyle(fontStyle: FontStyle.italic)),
TextSpan(text: 'world', style: TextStyle(fontWeight: FontWeight.bold)),
],
),
)
],
)
),
);
}
}

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :