加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 建站 > 正文

为前端工程师筹备的Flutter入门指南

发布时间:2019-01-22 07:57:16 所属栏目:建站 来源:佚名
导读:假如你刚好是一名前端工程师,且对 Flutter 抱有乐趣,那么真的是太好了,这篇文章完全就是为你筹备的。写惯了 HTML、CSS 与 JavaScript,要不要来是试试 Dart?假如你不认识 Flutter 但仍对其感乐趣,可以先看看「让我们在2019年从头熟悉 Flutter」一文相识

Web

  1. <div class="greybox"> 
  2.   <div class="redbox"> 
  3.     Lorem <em>ipsum</em>  
  4.   </div> 
  5. </div> 
  6.  
  7. .greybox { 
  8.   background-color: #e0e0e0; /* grey 300 */ 
  9.   width: 320px; 
  10.   height: 240px; 
  11.   font: 900 24px Roboto;  
  12.   display: flex; 
  13.   align-items: center; 
  14.   justify-content: center; 
  15. .redbox { 
  16.   background-color: #ef5350; /* red 400 */ 
  17.   padding: 16px; 
  18.   color: #ffffff; 
  19.  .redbox em { 
  20.   font: 300 48px Roboto; 
  21.   font-style: italic; 
  22. }  

Dart

  1. var container = Container( // grey box 
  2.   child: Center( 
  3.     child: Container( // red box 
  4.       child:  RichText( 
  5.         text: TextSpan( 
  6.           style: bold24Roboto, 
  7.           children: <TextSpan>[ 
  8.             TextSpan(text: "Lorem "), 
  9.             TextSpan( 
  10.               text: "ipsum", 
  11.               style: TextStyle( 
  12.                 fontWeight: FontWeight.w300, 
  13.                 fontStyle: FontStyle.italic, 
  14.                 fontSize: 48.0, 
  15.               ), 
  16.             ), 
  17.           ], 
  18.         ), 
  19.       ),  
  20.       decoration: BoxDecoration( 
  21.         backgroundColor: Colors.red[400], 
  22.       ), 
  23.       padding: EdgeInsets.all(16.0), 
  24.     ), 
  25.   ), 
  26.   width: 320.0, 
  27.   height: 240.0, 
  28.   color: Colors.grey[300], 
  29. ); 

4.3 文本择要

在 Web 中,我们常用省略号处理赏罚溢出的文本内容,且在 HTML/CSS 中,择要不能高出一行。 假如要在多行之后举办截断,那么就必要 JavaScript 的辅佐了。

在 Flutter 中,行使 Text widget 的 maxLines 属性来指定包括在择要中的行数,以及 overflow 属性来处理赏罚溢出文本。

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读