54 lines
1.4 KiB
Dart
54 lines
1.4 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class TextWidgets extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text("基础文本控件"),
|
|
backgroundColor: Colors.blue,
|
|
),
|
|
body: TextWidgetsBody(),
|
|
);
|
|
}
|
|
}
|
|
|
|
class TextWidgetsBody extends StatefulWidget {
|
|
@override
|
|
State<StatefulWidget> createState() {
|
|
return TextWidgetsBodyState();
|
|
}
|
|
}
|
|
|
|
class TextWidgetsBodyState extends State<TextWidgetsBody> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
Text("基础文本,居中显示"*4, textAlign: TextAlign.center,),
|
|
Text("尾部省略的文本"*4, maxLines: 1, overflow: TextOverflow.visible,),
|
|
Text("放大的文本", textScaler: TextScaler.linear(1.5),),
|
|
Text("文本样式测试", style: TextStyle(
|
|
color: Colors.amber,
|
|
fontFamily: "Courier",
|
|
decoration: TextDecoration.lineThrough
|
|
),),
|
|
Text.rich(TextSpan(
|
|
children: [
|
|
TextSpan(text: "富文本测试:"),
|
|
TextSpan(text: "http://www.baidu.com",
|
|
style: TextStyle(
|
|
decoration: TextDecoration.underline,
|
|
decorationColor: Colors.blue,
|
|
color: Colors.blue
|
|
),
|
|
)
|
|
]
|
|
))
|
|
],
|
|
|
|
);
|
|
}
|
|
|
|
} |