01 | class MyApp extends StatelessWidget { |
02 | const MyApp({Key key}) : super (key: key); |
03 |
04 | @override |
05 | Widget build(BuildContext context) { |
06 | return MaterialApp( |
07 | title: 'Text文本组件' , |
08 | home: Scaffold( |
09 | appBar: AppBar( |
10 | title: Text( 'Text文本组件' ), |
11 | ), |
12 | body: Text( |
13 | 'hello world' , |
14 | style: TextStyle( |
15 | //字体 |
16 | //1、将ttf字体文件放到根目录的assets/fonts中, |
17 | //2、在pubspec.yaml中配置字体路径,同时设置字体类型的名称 |
18 | // fonts: |
19 | // - family: fzzqt |
20 | // fonts: |
21 | // - asset: assets/fonts/fzzqt.ttf |
22 | // style: italic |
23 | //3、在fontFamily后面加上字体名称即可 |
24 | fontFamily: 'fzzqt' , |
25 | fontSize: 36.0, |
26 | color: Colors.red, |
27 | //加粗 |
28 | fontWeight: FontWeight.bold, |
29 | //文字修饰 |
30 | //TextDecoration.lineThrough, TextDecoration.underline,TextDecoration.overline,TextDecoration.none |
31 | decoration: TextDecoration.overline, |
32 | //修饰符样式 点虚线 |
33 | decorationStyle: TextDecorationStyle.dotted, |
34 | //修饰符颜色 |
35 | decorationColor: Colors.black, |
36 | ), |
37 | ), |
38 | ), |
39 | ); |
40 | } |
41 | } |