0x03-0x0101.显示组件-文字(Text)

文字(Text)是最基础的的组件,本节将介绍此组件的各属性。

示例代码:

   Text("文字示例")

效果:

效果图

取值:

说明
true 允许自动换行
false 不允许自动换行

示例代码:

   // true
   child: Text(
       "文字示例 Text Sample 文字示例 Text Sample 文字示例 Text Sample 文字示例 Text Sample 文字示例 Text Sample",
       softWrap: true,
   )
   // false
   child: Text(
       "文字示例 Text Sample 文字示例 Text Sample 文字示例 Text Sample 文字示例 Text Sample 文字示例 Text Sample",
       softWrap: false,
   )

效果: 效果图

取值:

说明
TextAlign.left 左对齐
TextAlign.center 居中对齐
TextAlign.right 右对齐
TextAlign.start 以容器起始端对齐
TextAlign.end 以容器结束端对齐
TextAlign.justify 自动换行拉伸填充,硬换行起始对齐

left、center、right相当于绝对方式,不受容器属性影响。

start、end受容器的textDirection影响,当容器为TextDirection.ltr时,start为左对齐,end为右对齐;当容器为TextDirection.rtl时,start为右对齐,end为左对齐。

justify会将自动换行的内容拉伸单词间距将容器填充满。

效果: 效果图

待续