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

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

发布时间:2019-01-29 15:50:13 所属栏目:优化 来源:佚名
导读:如果你恰好是一名前端工程师,且对 Flutter 抱有兴趣,那么真的是太好了,这篇文章完全就是为你准备的。写惯了 HTML、CSS 与 JavaScript,要不要来是试试 Dart?如果你不熟悉 Flutter 但仍对其感兴趣,可以先看看「让我们在2019年重新认识 Flutter」一文了解

Web

  1. <div class="greybox"> 
  2.   <div class="redbox"> 
  3.     Lorem ipsum 
  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.   transform: scale(1.5);  

Dart

  1. var container = Container( // gray box 
  2.   child: Center( 
  3.     child:  Transform( 
  4.       child:  Container( // red box 
  5.         child: Text( 
  6.           "Lorem ipsum", 
  7.           style: bold24Roboto, 
  8.           textAlign: TextAlign.center, 
  9.         ), 
  10.         decoration: BoxDecoration( 
  11.           color: Colors.red[400], 
  12.         ), 
  13.         padding: EdgeInsets.all(16.0), 
  14.       ), 
  15.       alignment: Alignment.center, 
  16.       transform: Matrix4.identity() 
  17.         ..scale(1.5), 
  18.      ),  
  19.   width: 320.0, 
  20.   height: 240.0, 
  21.   color: Colors.grey[300], 
  22. ); 

2.4 线性变换

将元素嵌套在一个 Container widget 中,可以将线性变换应用在 widget 的背景上。之后,再用 Container widget 的 decoration 属性生成一个 BoxDecoration 对象,然后使用 BoxDecoration 的 gradient 属性来变换背景填充内容。

变换“角度”基于 Alignment (x, y) 取值来定:

  • 如果开始和结束的 x 值相同,变换将是垂直的(0°180°)。
  • 如果开始和结束的 y 值相同,变换将是水平的(90°270°)。

这里,只展示垂直变换的代码差异:

Web

  1. <div class="greybox"> 
  2.   <div class="redbox"> 
  3.     Lorem ipsum 
  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.   padding: 16px; 
  17.   color: #ffffff; 
  18.   background: linear-gradient(180deg, #ef5350, rgba(0, 0, 0, 0) 80%);  

(编辑:威海站长网)

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

热点阅读