码迷,mamicode.com
首页 > 其他好文 > 详细

flutter 基础组件

时间:2019-04-30 09:24:06      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:组件   pre   ide   title   The   color   ica   splay   sed   

TextWidget

 1 class TextWidget extends StatelessWidget {
 2     final TextStyle _textStyle = TextStyle(
 3         fontSize: 16.0,
 4     );
 5     final String _auther = 李白;
 6     final String _title = 将进酒;
 7 
 8 
 9     @override
10     Widget build(BuildContext context) {
11         return Text(
12             // 插值写法$_value
13             《$_title》是唐代大诗人$_auther沿用乐府古题创作的一首诗。此诗为李白长安放还以后所作,思想内容非常深沉,艺术表现非常成熟,在同题作品中影响最大。诗人豪饮高歌,借酒消愁,抒发了忧愤深广的人生感慨。诗中交织着失望与自信、悲愤与抗争的情怀,体现出强烈的豪纵狂放的个性。,
14             // 对齐
15             textAlign: TextAlign.left,
16             // 字体样式
17             style: _textStyle,
18             // 文本最大行数
19             maxLines: 3,
20             // 若溢出的处理办法
21             overflow: TextOverflow.ellipsis,   
22         );
23     }
24 }

RichTextWidget

技术图片
 1 class BasicalWidgetDemo extends StatelessWidget {
 2     
 3     @override
 4     Widget build(BuildContext context) {
 5         return RichText(
 6             text: TextSpan(
 7                 // 必填
 8                 text:  licangxuan,
 9                 style: TextStyle(
10                     color: Colors.deepPurpleAccent,
11                     fontSize: 36.0,
12                     // 斜体
13                     fontStyle: FontStyle.italic,
14                     fontWeight: FontWeight.w100
15                 ),
16                 children: [
17                     TextSpan(
18                         text: .net,
19                         style: TextStyle(
20                             color: Colors.black,
21                             fontSize: 16.0,
22                             fontWeight: FontWeight.w400
23                         ) 
24                     )
25                 ]
26             ),
27         );
28     }
29 }
View Code

技术图片

 

flutter 基础组件

标签:组件   pre   ide   title   The   color   ica   splay   sed   

原文地址:https://www.cnblogs.com/liwenchi/p/10793766.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!