Flutter Text Widgets
Flutter Text Widgets由*Text* ,RichText ,DefaultTextStyle 构成。
- Text由单一的样式来显示文本;
构造函数:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15const Text(this.data, {
Key key,
this.style,
this.strutStyle,
this.textAlign,
this.textDirection,
this.locale,
this.softWrap,
this.overflow,
this.textScaleFactor,
this.maxLines,
this.semanticsLabel,
}) : assert(data != null),
textSpan = null,
super(key: key); - RichText由多种不同的样式来显示文本;
构造函数:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18const RichText({
Key key,
this.text,
this.textAlign = TextAlign.start,
this.textDirection,
this.softWrap = true,
this.overflow = TextOverflow.clip,
this.textScaleFactor = 1.0,
this.maxLines,
this.locale,
this.strutStyle,
}) : assert(text != null),
assert(textAlign != null),
assert(softWrap != null),
assert(overflow != null),
assert(textScaleFactor != null),
assert(maxLines == null || maxLines > 0),
super(key: key); - DefaultTextStyle对于没有明确样式的子文本元素设置默认的文本样式;
构造函数:
1
2
3
4
5
6
7
8
9
10
11
12
13
14const DefaultTextStyle({
Key key,
this.style,
this.textAlign,
this.softWrap = true,
this.overflow = TextOverflow.clip,
this.maxLines,
Widget child,
}) : assert(style != null),
assert(softWrap != null),
assert(overflow != null),
assert(maxLines == null || maxLines > 0),
assert(child != null),
super(key: key, child: child);