11import 'package:flutter/material.dart' ;
2- //import 'package:flutter_markdown/flutter_markdown.dart';
32import '../../../../../common/widget_demo.dart' ;
4- import '../../../../../components/markdown .dart' ;
3+ import 'demo .dart' ;
54
65const String intro = """
7- # 说明
6+ ### **简介**
87
98> 具有某个单一样式的文本显示的widget组件, 显示支持一行或者多行. 默认样式会继承层级最为接近的 *DefaultStyle*
109当然, 你也可以重新他的样式 将 *DefaultStyle.inherit 设置为 false*
1110
12- # 示例代码
11+ 是最基本的文本显示组件
1312
14- ``` dart
15- Text(
16- 'Hello, World ! How are you?',
17- textAlign: TextAlign.center,
18- overflow: TextOverflow.ellipsis,
19- style: TextStyle(fontWeight: FontWeight.bold),
20- )
21- ```
13+ ### **基本用法**
14+ 在这里介绍一下他的基本属性说明.
2215
23- # 示例显示
16+ - data Text显示的文本,必填参数 String
17+ - textAlign 文本的对齐方式,可以选择左对齐、右对齐还是居中对齐 TextAlign
18+ - maxLines 文本显示的最大行数 int
19+ - overflow 文本显示的截断方式 TextOverflow
20+ - textScaleFactor 文本的缩放比例 double
21+ - style 用于指定文本显示的样式如颜色、字体、粗细、背景等
2422
2523
26- """ ;
27-
28- const String leftDesc = """
29- # 示例代码
30-
31-
32- ``` dart
33- // 左侧布局示例
34- Text(
35- "Hello, World! I'm start from left?",
36- textAlign: TextAlign.left,
37- overflow: TextOverflow.ellipsis,
38- style: TextStyle(fontWeight: FontWeight.bold, inherit: true),
39- ),
40- ```
41- # 示例显示
42- """ ;
43-
44- const String RichDesc = """
45-
46- # 复杂文本显示
47-
48- 使用 Text.rich 构造函数,Text 组件可以显示具有不同样式的 TextSpan 段落。下面的示例显示每个单词具有不同样式的“Hello beautiful world”。
24+ ### **基本示例**
4925
50- ```
51- Text.rich(
52- TextSpan(
53- text: 'Hello', // default text style
54- children: <TextSpan>[
55- TextSpan(text: ' beautiful ', style: TextStyle(fontStyle: FontStyle.italic)),
56- TextSpan(text: 'world', style: TextStyle(fontWeight: FontWeight.bold)),
57- ],
58- ),
59- )
60- ```
6126""" ;
6227
63- const Map <String , String > markDesc = {
64- "intro" : intro,
65- "left" : leftDesc,
66- "rich" : RichDesc
67- };
6828class Demo extends StatefulWidget {
6929 static const String routeName = '/element/Form/Text/Text' ;
7030 _Demo createState () => _Demo ();
@@ -79,38 +39,10 @@ class _Demo extends State<Demo> {
7939 title: "Text" ,
8040 docUrl: 'flutter/widgets/Text-class.html' ,
8141 codeUrl: 'elements/Form/Text/Text/index.dart' ,
82- contentList: [new Column (
83- children: < Widget > [
84- MarkdownBody (markDesc['intro' ]),
85- Text (
86- 'Hello, World! How are you?' ,
87- textAlign: TextAlign .center,
88- overflow: TextOverflow .ellipsis,
89- style: TextStyle (fontWeight: FontWeight .bold),
90- ),
91- MarkdownBody (markDesc['left' ]),
92- Container (
93- width: 750.0 ,
94- color: Color (0xFF0096ef ),
95- child: Text (
96- "Hello, World! I'm start from left?" ,
97- textAlign: TextAlign .left,
98- overflow: TextOverflow .ellipsis,
99- style: TextStyle (color: Color (0xffffffff )),
100- ),
101- ),
102- MarkdownBody ( markDesc['rich' ]),
103- Text .rich (
104- TextSpan (
105- text: 'Hello' , // default text style
106- children: < TextSpan > [
107- TextSpan (text: ' beautiful ' , style: TextStyle (fontStyle: FontStyle .italic)),
108- TextSpan (text: 'world' , style: TextStyle (fontWeight: FontWeight .bold)),
109- ],
110- ),
111- )
112- ],
113- )]
42+ contentList: [
43+ intro,
44+ TextDemo (),
45+ ]
11446 );
11547 }
11648}
0 commit comments