Flutter有一套丰富、强大的基础widget,其中以下是很常用的:
Text:
const Text(
this.data, { //data就是我们需要展示的文字,这个是必传字段,其他的都是可选
Key key, //widget的标识
this.style, //文本样式,类型是TextStyle
this.strutStyle, //段落样式,类型是StrutStyle
this.textAlign, //文本的对齐方式,类型是TextAlign
this.textDirection, // 文字方向,类型是TextDirection
this.locale, //选择用户语言和格式的标识符,类型是Locale
this.softWrap, //bool 类型 ,false标识文本只有一行,水平方向无限
this.overflow, //文本的阶段方式,类型是TextOverflow
this.textScaleFactor,//double类型 表示文本相对于当前字体的缩放因子,默认为1.0
this.maxLines,// int 类型,显示的最大行数
this.semanticsLabel, //String 类型,给文本加上一个语义标签,没有实际用处
this.textWidthBasis,//一行或多行文本宽度的不同方式,类型是TextWidthBasis
}) : assert(
data != null,
'A non-null String must be provided to a Text widget.',
),
textSpan = null,
super(key: key);
代码:
class MyApp extends StatelessWidget{
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: "flutter demo",
home: Center(
child: Text(
'Hello, world! TextStyle 配置文本的显示样式 和 输入文本的样式', ,
// "Text组件的使用",
style: TextStyle(
// 文字颜色
color: Colors.yellow,
// none 不显示装饰线条,underline 字体下方,overline 字体上方,lineThrough穿过文字
decoration: TextDecoration.none,
// solid 直线,double 双下划线,dotted 虚线,dashed 点下划线,wavy 波浪线
decorationStyle: TextDecorationStyle.solid,
// 装饰线的