欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

分享Flutter入門指南

這篇文章主要講解了“分享Flutter入門指南”,文中的講解內(nèi)容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“分享Flutter入門指南”吧!

創(chuàng)新互聯(lián)堅持“要么做到,要么別承諾”的工作理念,服務領域包括:成都網(wǎng)站制作、網(wǎng)站建設、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣等服務,滿足客戶于互聯(lián)網(wǎng)時代的前郭網(wǎng)站設計、移動媒體設計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡建設合作伙伴!

一、基礎布局

先來看看最常見的一些 UI 布局操作。

1.1 文本樣式與對齊

我們在 CSS 中設置的字體樣式、大小以及其他文本屬性,都是 Flutter 中一個 Text widget 子元素 TextStyle  中單獨的屬性。

In both HTML and Flutter, child elements or widgets are anchored at the top  left, by default.

不論是 HTML 還是 Flutter,子元素或者 widget 都默認錨定在左上方。

Web

<div class="greybox">     Lorem ipsum </div>  .greybox {   background-color: #e0e0e0; /* grey 300 */   width: 320px;   height: 240px;   font: 900 24px Georgia; }

Dart

var container = Container( // grey box   child: Text(     "Lorem ipsum",     style: TextStyle(       fontSize: 24.0,       fontWeight: FontWeight.w900,       fontFamily: "Georgia",     ),   ),   width: 320.0,   height: 240.0,   color: Colors.grey[300], );

1.2 背景顏色

在 Flutter 中,你可以通過 Container 的 decoration 屬性來設置背景顏色。

CSS 示例中我們使用等價的十六進制顏色表示。

Web

<div class="greybox">   Lorem ipsum </div>  .greybox {   background-color: #e0e0e0;  /* grey 300 */   width: 320px;   height: 240px;   font: 900 24px Roboto; }

Dart

var container = Container( // grey box     child: Text(       "Lorem ipsum",       style: bold24Roboto,     ),     width: 320.0,     height: 240.0,     color: Colors.grey[300],   );

1.3 居中元素

在 Flutter 中,Center widget 可以將它的子元素水平和垂直居中。

要用 CSS 實現(xiàn)相似的效果,其父元素則需要使用一個 flex 或者 table-cell 顯示布局。本節(jié)示例使用的是 flex 布局。

Web

<div class="greybox">   Lorem ipsum </div>  .greybox {   background-color: #e0e0e0; /* grey 300 */   width: 320px;   height: 240px;   font: 900 24px Roboto;   display: flex;   align-items: center;   justify-content: center;  }

Dart

var container = Container( // grey box   child:  Center(     child:  Text(       "Lorem ipsum",       style: bold24Roboto,     ),   ),   width: 320.0,   height: 240.0,   color: Colors.grey[300], );

1.4 設置容器寬度

Container widget 的寬度可以用它的 width 屬性指定,但需要注意的是,和 CSS 中的 max-width  屬性用于指定容器可調(diào)整的***寬度值不同的是,這里指定的是一個固定寬度。要在 Flutter 中模擬 max-width 的效果,可以使用 Container 的  constraints 屬性。新建一個帶有 minWidth 和 maxWidth 屬性的 BoxConstraints widget。 而對嵌套的  Container 來說,如果其父元素寬度小于子元素寬度,則子元素實際尺寸以父元素大小為準。

Web

<div class="greybox">   <div class="redbox">     Lorem ipsum   </div> </div>  .greybox {   background-color: #e0e0e0; /* grey 300 */   width: 320px;    height: 240px;   font: 900 24px Roboto;   display: flex;   align-items: center;   justify-content: center; } .redbox {   background-color: #ef5350; /* red 400 */   padding: 16px;   color: #ffffff;   width: 100%;   max-width: 240px;  }

Dart

var container = Container( // grey box   child: Center(     child: Container( // red box       child: Text(         "Lorem ipsum",         style: bold24Roboto,       ),       decoration: BoxDecoration(         color: Colors.red[400],       ),       padding: EdgeInsets.all(16.0),       width: 240.0, //max-width is 240.0     ),   ),   width: 320.0,    height: 240.0,   color: Colors.grey[300], );

二、位置與大小

以下示例將展示如何對 widget 的位置、大小以及背景進行更復雜的操作。

2.1 絕對定位

默認情況下, widget 是相對于其父元素定位的。要通過 x-y 坐標指定一個 widget 的絕對位置,請把它嵌套在一個 Positioned  widget 中,而該 widget 則需被嵌套在一個 Stack widget 中。

Web

<div class="greybox">   <div class="redbox">     Lorem ipsum   </div> </div>  .greybox {   background-color: #e0e0e0; /* grey 300 */   width: 320px;   height: 240px;   font: 900 24px Roboto;   position: relative;  } .redbox {   background-color: #ef5350; /* red 400 */   padding: 16px;   color: #ffffff;   position: absolute;   top: 24px;   left: 24px;  }

Dart

var container = Container( // grey box   child: Stack(     children: [       Positioned( // red box         child:  Container(           child: Text(             "Lorem ipsum",             style: bold24Roboto,           ),           decoration: BoxDecoration(             color: Colors.red[400],           ),           padding: EdgeInsets.all(16.0),         ),         left: 24.0,         top: 24.0,       ),     ],   ),    width: 320.0,   height: 240.0,   color: Colors.grey[300], );

2.2 旋轉(zhuǎn)

要旋轉(zhuǎn)一個 widget,請將它嵌套在 Transform widget 中。其中,使用 Transform widget 的 alignment 和  origin 屬性分別來指定轉(zhuǎn)換原點的具體位置信息。

對于簡單的 2D 旋轉(zhuǎn),widget 是依據(jù)弧度在 Z 軸上旋轉(zhuǎn)的。(角度 &times; &pi; / 180)

Web 

<div class="greybox">   <div class="redbox">     Lorem ipsum   </div> </div>  .greybox {   background-color: #e0e0e0; /* grey 300 */   width: 320px;   height: 240px;   font: 900 24px Roboto;   display: flex;   align-items: center;   justify-content: center; } .redbox {   background-color: #ef5350; /* red 400 */   padding: 16px;   color: #ffffff;   transform: rotate(15deg);  }

Dart

var container = Container( // gray box   child: Center(     child:  Transform(       child:  Container( // red box         child: Text(           "Lorem ipsum",           style: bold24Roboto,           textAlign: TextAlign.center,         ),         decoration: BoxDecoration(           color: Colors.red[400],         ),         padding: EdgeInsets.all(16.0),       ),       alignment: Alignment.center,       transform: Matrix4.identity()         ..rotateZ(15 * 3.1415927 / 180),     ),    ),   width: 320.0,   height: 240.0,   color: Colors.grey[300], );

2.3 縮放元素

將元素嵌套在一個 Transform widget 中,可以實現(xiàn)縮放。使用 Transform widget 的 alignment 和 origin  屬性分別來指定縮放原點的具體位置信息。

對于沿 x 軸的簡單縮放操作,新建一個 Matrix4 標識對象并用它的 scale() 方法來指定縮放因系數(shù)。

當你縮放一個父 widget 時,它的子 widget 也會相應被縮放。

Web

<div class="greybox">   <div class="redbox">     Lorem ipsum   </div> </div>  .greybox {   background-color: #e0e0e0; /* grey 300 */   width: 320px;   height: 240px;   font: 900 24px Roboto;   display: flex;   align-items: center;   justify-content: center; } .redbox {   background-color: #ef5350; /* red 400 */   padding: 16px;   color: #ffffff;   transform: scale(1.5);  }

Dart

var container = Container( // gray box   child: Center(     child:  Transform(       child:  Container( // red box         child: Text(           "Lorem ipsum",           style: bold24Roboto,           textAlign: TextAlign.center,         ),         decoration: BoxDecoration(           color: Colors.red[400],         ),         padding: EdgeInsets.all(16.0),       ),       alignment: Alignment.center,       transform: Matrix4.identity()         ..scale(1.5),      ),    width: 320.0,   height: 240.0,   color: Colors.grey[300], );

2.4 線性變換

將元素嵌套在一個 Container widget 中,可以將線性變換應用在 widget 的背景上。之后,再用 Container widget 的  decoration 屬性生成一個 BoxDecoration 對象,然后使用 BoxDecoration 的 gradient  屬性來變換背景填充內(nèi)容。

變換“角度”基于 Alignment (x, y) 取值來定:

  • 如果開始和結(jié)束的 x 值相同,變換將是垂直的(0&deg;180&deg;)。

  • 如果開始和結(jié)束的 y 值相同,變換將是水平的(90&deg;270&deg;)。

這里,只展示垂直變換的代碼差異:

Web 

<div class="greybox">   <div class="redbox">     Lorem ipsum   </div> </div>  .greybox {   background-color: #e0e0e0; /* grey 300 */   width: 320px;   height: 240px;   font: 900 24px Roboto;   display: flex;   align-items: center;   justify-content: center; } .redbox {   padding: 16px;   color: #ffffff;   background: linear-gradient(180deg, #ef5350, rgba(0, 0, 0, 0) 80%);  }

Dart

var container = Container( // grey box   child: Center(     child: Container( // red box       child: Text(         "Lorem ipsum",         style: bold24Roboto,       ),       decoration: BoxDecoration(         gradient: LinearGradient(           begin: const Alignment(0.0, -1.0),           end: const Alignment(0.0, 0.6),           colors: <Color>[             const Color(0xffef5350),             const Color(0x00ef5350)           ],         ),       ),        padding: EdgeInsets.all(16.0),     ),   ),   width: 320.0,   height: 240.0,   color: Colors.grey[300], );

三、圖形/形狀

以下示例將展示如何新建和自定義圖形。

3.1 圓角

在矩形上實現(xiàn)圓角,可以用 BoxDecoration 對象的 borderRadius 屬性。新建一個 BorderRadius  對象來指定每個圓角的半徑大小。

Web

<div class="greybox">   <div class="redbox">     Lorem ipsum   </div> </div>  .greybox {   background-color: #e0e0e0; /* gray 300 */   width: 320px;   height: 240px;   font: 900 24px Roboto;   display: flex;   align-items: center;   justify-content: center; } .redbox {   background-color: #ef5350; /* red 400 */   padding: 16px;   color: #ffffff;   border-radius: 8px;  }

Dart

var container = Container( // grey box   child: Center(     child: Container( // red circle       child: Text(         "Lorem ipsum",         style: bold24Roboto,       ),       decoration: BoxDecoration(         color: Colors.red[400],         borderRadius: BorderRadius.all(           const Radius.circular(8.0),         ),        ),       padding: EdgeInsets.all(16.0),     ),   ),   width: 320.0,   height: 240.0,   color: Colors.grey[300], );

3.2 陰影

在 CSS 中你可以通過 box-shadow 屬性快速指定陰影偏移與模糊范圍。比如如下兩個盒陰影的屬性設置:

  • xOffset: 0px, yOffset: 2px, blur: 4px, color: black @80% alpha

  • xOffset: 0px, yOffset: 06x, blur: 20px, color: black @50% alpha

在 Flutter 中,每個屬性與其取值都是單獨指定的。請使用 BoxDecoration 的 boxShadow 屬性來生成一系列 BoxShadow  widget。你可以定義一個或多個 BoxShadow widget,這些 widget 共同用于設置陰影深度、顏色等等。

Web

<div class="greybox">   <div class="redbox">     Lorem ipsum   </div> </div>  .greybox {   background-color: #e0e0e0; /* grey 300 */   width: 320px;   height: 240px;   font: 900 24px Roboto;   display: flex;   align-items: center;   justify-content: center; } .redbox {   background-color: #ef5350; /* red 400 */   padding: 16px;   color: #ffffff;   box-shadow: 0 2px 4px rgba(0, 0, 0, 0.8),               0 6px 20px rgba(0, 0, 0, 0.5); }

Dart

var container = Container( // grey box   child: Center(     child: Container( // red box       child: Text(         "Lorem ipsum",         style: bold24Roboto,       ),       decoration: BoxDecoration(         color: Colors.red[400],         boxShadow: <BoxShadow>[           BoxShadow (             color: const Color(0xcc000000),             offset: Offset(0.0, 2.0),             blurRadius: 4.0,           ),           BoxShadow (             color: const Color(0x80000000),             offset: Offset(0.0, 6.0),             blurRadius: 20.0,           ),         ],        ),       padding: EdgeInsets.all(16.0),     ),   ),   width: 320.0,   height: 240.0,   decoration: BoxDecoration(     color: Colors.grey[300],   ),   margin: EdgeInsets.only(bottom: 16.0), );

3.3 圓與橢圓

盡管 CSS 中有基礎圖形,CSS 中一個生成圓的變通方案是:將矩形的四邊 border-radius 均設成50%。

雖然 BoxDecoration 的 borderRadius 屬性支持這樣設置,F(xiàn)lutter 為 BoxShape enum 提供一個 shape  屬性也用于實現(xiàn)同樣的目的。

Web 

<div class="greybox">   <div class="redcircle">     Lorem ipsum   </div> </div>  .greybox {   background-color: #e0e0e0; /* gray 300 */   width: 320px;   height: 240px;   font: 900 24px Roboto;   display: flex;   align-items: center;   justify-content: center; } .redcircle {   background-color: #ef5350; /* red 400 */   padding: 16px;   color: #ffffff;   text-align: center;   width: 160px;   height: 160px;   border-radius: 50%;  }

Dart

var container = Container( // grey box   child: Center(     child: Container( // red circle       child: Text(         "Lorem ipsum",         style: bold24Roboto,         textAlign: TextAlign.center,        ),       decoration: BoxDecoration(         color: Colors.red[400],         shape: BoxShape.circle,        ),       padding: EdgeInsets.all(16.0),       width: 160.0,       height: 160.0,      ),   ),   width: 320.0,   height: 240.0,   color: Colors.grey[300], );

四、文本

以下示例展示了如何設置字體和其他文本屬性,除此外還包括一些特性比如如何變換文本字符、自定義間距以及生成摘錄。

4.1 文字間距

在 CSS 中你可以通過分別給 letter-spacing 和 word-spacing  屬性的長度賦值來指定每個字母以及每個單詞間的空白距離。距離的單位可以是 px, pt, cm, em 等等。

在 Flutter 中,你可以在 Text widget 子元素 TextStyle 的 letterSpacing 與 wordSpacing  屬性中將間距設置為邏輯像素(允許負值)。

Web 

<div class="greybox">   <div class="redbox">     Lorem ipsum   </div> </div>  .greybox {   background-color: #e0e0e0; /* grey 300 */   width: 320px;   height: 240px;   font: 900 24px Roboto;   display: flex;   align-items: center;   justify-content: center; } .redbox {   background-color: #ef5350; /* red 400 */   padding: 16px;   color: #ffffff;   letter-spacing: 4px;  }

Dart

var container = Container( // grey box   child: Center(     child: Container( // red box       child: Text(         "Lorem ipsum",         style: TextStyle(           color: Colors.white,           fontSize: 24.0,           fontWeight: FontWeight.w900,           letterSpacing: 4.0,          ),       ),       decoration: BoxDecoration(         color: Colors.red[400],       ),       padding: EdgeInsets.all(16.0),     ),   ),   width: 320.0,   height: 240.0,   color: Colors.grey[300], );

4.2 內(nèi)聯(lián)樣式

一個 Text widget 可以展示同一類樣式的文本。為了展現(xiàn)具有多種樣式的文本,需要改用 RichText widget。它的 text  屬性可以指定一個或多個可以單獨設置樣式的 TextSpan widget。

在下例中,”Lorem” 位于 TextSpan widget 中,具有默認(繼承自其父元素)文本樣式,”ipsum” 位于具有自定義樣式、單獨的一個  TextSpan 中。

Web 

<div class="greybox">   <div class="redbox">     Lorem <em>ipsum</em>    </div> </div>  .greybox {   background-color: #e0e0e0; /* grey 300 */   width: 320px;   height: 240px;   font: 900 24px Roboto;    display: flex;   align-items: center;   justify-content: center; } .redbox {   background-color: #ef5350; /* red 400 */   padding: 16px;   color: #ffffff; }  .redbox em {   font: 300 48px Roboto;   font-style: italic; }

Dart

var container = Container( // grey box   child: Center(     child: Container( // red box       child:  RichText(         text: TextSpan(           style: bold24Roboto,           children: <TextSpan>[             TextSpan(text: "Lorem "),             TextSpan(               text: "ipsum",               style: TextStyle(                 fontWeight: FontWeight.w300,                 fontStyle: FontStyle.italic,                 fontSize: 48.0,               ),             ),           ],         ),       ),        decoration: BoxDecoration(         backgroundColor: Colors.red[400],       ),       padding: EdgeInsets.all(16.0),     ),   ),   width: 320.0,   height: 240.0,   color: Colors.grey[300], );

4.3 文本摘要

在 Web 中,我們常用省略號處理溢出的文本內(nèi)容,且在 HTML/CSS 中,摘要不能超過一行。 如果要在多行之后進行截斷,那么就需要  JavaScript 的幫助了。

在 Flutter 中,使用 Text widget 的 maxLines 屬性來指定包含在摘要中的行數(shù),以及 overflow  屬性來處理溢出文本。

Web 

<div class="greybox">   <div class="redbox">     Lorem ipsum dolor sit amet, consec etur   </div> </div>  .greybox {   background-color: #e0e0e0; /* grey 300 */   width: 320px;   height: 240px;   font: 900 24px Roboto;   display: flex;   align-items: center;   justify-content: center; } .redbox {   background-color: #ef5350; /* red 400 */   padding: 16px;   color: #ffffff;   overflow: hidden;   text-overflow: ellipsis;   white-space: nowrap;  }

Dart

var container = Container( // grey box   child: Center(     child: Container( // red box       child: Text(         "Lorem ipsum dolor sit amet, consec etur",         style: bold24Roboto,         overflow: TextOverflow.ellipsis,         maxLines: 1,        ),       decoration: BoxDecoration(         backgroundColor: Colors.red[400],       ),       padding: EdgeInsets.all(16.0),     ),   ),   width: 320.0,   height: 240.0,   color: Colors.grey[300], );

感謝各位的閱讀,以上就是“分享Flutter入門指南”的內(nèi)容了,經(jīng)過本文的學習后,相信大家對分享Flutter入門指南這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關知識點的文章,歡迎關注!

文章名稱:分享Flutter入門指南
網(wǎng)頁網(wǎng)址:http://chinadenli.net/article24/ppsoje.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、定制網(wǎng)站、外貿(mào)網(wǎng)站建設、企業(yè)建站、靜態(tài)網(wǎng)站、商城網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁設計
亚洲欧美一二区日韩高清在线| 俄罗斯胖女人性生活视频| 国产福利一区二区久久| 欧美国产日产在线观看| 熟女少妇一区二区三区蜜桃| 欧美成人精品国产成人综合| 欧美久久一区二区精品| 亚洲国产日韩欧美三级| 人妻中文一区二区三区| 国产一区二区三区精品免费| 极品少妇嫩草视频在线观看| 99日韩在线视频精品免费| 色婷婷久久五月中文字幕| 大尺度激情福利视频在线观看| 精品国产品国语在线不卡| 丝袜破了有美女肉体免费观看| 亚洲午夜精品视频观看| 日本一品道在线免费观看| 在线视频免费看你懂的| 亚洲综合伊人五月天中文 | 日本一本不卡免费视频| 成人精品亚洲欧美日韩| 日韩在线中文字幕不卡| 欧美日韩视频中文字幕| 婷婷伊人综合中文字幕| 国产精品人妻熟女毛片av久| 中文字幕亚洲精品乱码加勒比| 国产一区麻豆水好多高潮| 91日韩在线观看你懂的| 亚洲最新中文字幕一区| 色一情一伦一区二区三| 欧美日韩久久精品一区二区| 国产精欧美一区二区三区久久| 又色又爽又无遮挡的视频| 久草视频在线视频在线观看| 激情视频在线视频在线视频| 欧美日韩免费观看视频| 噜噜中文字幕一区二区| 欧美黑人黄色一区二区| 国产成人精品国内自产拍| 好吊妞视频只有这里有精品|