}/// 通过 Text.rich() 构造 Text 对象/// 在 Text.rich() 中可以设置 TextSpan,其用于设置 Text 中的不同文本的不同样式final_text3 = constText.rich(TextSpan( text: 'webabcd\n',// default text stylestyle:TextStyle( color:Colors.red, ),/// TextSpan 内可以附加多个 TextSpan,你可以为每...
而text一般是所有语言中最长见得组件,所以先从TextWidget学起。 import'package:flutter/material.dart';voidmain()=>runApp(MyApp());classMyAppextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){returnMaterialApp(title:"Text Widget",home:Scaffold(body:Center(child:Text("昨夜雨疏风骤,浓睡不消...
solid实线,dashed虚线,dotted虚线(由点组成),double两行,wavy波浪线 decorationColor: 装饰颜色 同样它可以使用ARGB颜色值或者十六进制颜色码 child:Text("我是文本组件Text。我是文本组件Text。我是文本组件Text。我是文本组件Text。",textAlign:TextAlign.left,maxLines:1,overflow:TextOverflow.ellipsis,style:TextSty...
text: "plain text ", children: <TextSpan>[ TextSpan( text: "color", style: TextStyle(color: Colors.pinkAccent)), TextSpan(text: "fontSize", style: TextStyle(fontSize: 28)), TextSpan( text: "decoration", style: TextStyle(decoration: TextDecoration.lineThrough)), ], ), ) rich_text...
color: Colors.red, fontSize: 40, fontWeight: FontWeight.bold ); Widget build(BuildContext context) { // TODO: implement build return Center( child: Text( 'Hello Flutter', textDirection: TextDirection.ltr, style: _textStyle, )); }} 是不是发现我们的_text...
Line height 行高 child: Text('Hello, How are you? I am fine. Thank you', style: TextStyle(color: Colors.red.withOpacity(0.5),fontSize: 48.0,height: 5.0), ), 5、以上就是比较常用的文本组件的属性,更多更详细的可以参考网址:一键送达
const Text( this.data, { //data 就是我们需要展示的文字 是字符串类型,这个是必传字段,其他的都是可选 Key key, //widget的标识 this.style, //文本样式,类型是TextStyle this.strutStyle, //用来设置最小行高的参数 this.textAlign, //文本的对齐方式,类型是TextAlign this.textDirection, // 文字方向...
Widget build(BuildContext context) { return new MaterialApp(title: 'Flutter_Wieghts',home: Scaffold(appBar: AppBar(title: Text('Text Learn'),),body: Center(child: Text('Hello World'*4,style: TextStyle(inherit: true,color: Colors.white,fontSize: 30.0,fontWeight: FontWeight.w...
Text( "我是一个文本。我是一个文本ljdjfls。我是一个文本。我是一个文本。", style: TextStyle( decoration: TextDecoration.lineThrough, // 下划线、删除线等 decorationColor: Colors.red, // decoration 的颜色 decorationStyle: TextDecorationStyle.dashed, // 双下划线,间隔线之类的 ...
color: Colors.blue, //颜色 fontSize: 14, // 字体大小 fontWeight: FontWeight.bold), // 字体加粗 //文本背景颜色 ), ), ); } } 特别注意:在 Flutter 中,并不是每个 Widget 都有点击事件,如上述说的文本Text 就没有 解决方案:需用一个 GestureDetector 组件包住Text 组件 & 实现onTap() 事件 ...