Flutter構(gòu)建布局

1度帮、第一個布局

import?'package:flutter/material.dart';

//?Uncomment?lines?7?and?10?to?view?the?visual?layout?at?runtime.

//?import?'package:flutter/rendering.dart'?show?debugPaintSizeEnabled;

void?main()?{

??runApp(MyApp());

}

class?MyApp?extends?StatelessWidget{

??@override

??Widget?build(BuildContext?context)?{

????Widget?titleSection?=?Container(

??????padding:?const?EdgeInsets.only(bottom:?11,top:?11,left:?11),

??????color:?Colors.grey,

??????child:?Row(

????????children:?<Widget>[

??????????/*1*/

??????????Expanded(child:?Column(

????????????crossAxisAlignment:?CrossAxisAlignment.start,

????????????children:?<Widget>[

??????????????/*2*/

??????????????Container(

????????????????color:?Colors.lightGreen,

????????????????padding:?const?EdgeInsets.only(top:?0,bottom:?8,left:?0),

????????????????child:?Text('text1',style:?TextStyle(fontWeight:?FontWeight.bold),),

??????????????),

??????????????Text('text2',style:?TextStyle(color:?Colors.red[500]),),

????????????],

??????????)),

??????????Container(

????????????height:?100,

????????????color:?Colors.green,

????????????padding:?const?EdgeInsets.only(right:?0,top:?0),

????????????child:?Icon(Icons.star,color:?Colors.red[500],),

??????????),

??????????Container(

????????????height:?60,

????????????color:?Colors.greenAccent,

????????????padding:?const?EdgeInsets.only(right:?11,bottom:?0,left:?11),

????????????child:?Text('413242342342',),

??????????),

????????],

??????),

????);

?????var?color?=?Theme.of(context).primaryColor;

?????var?bottonSection?=?Container(

???????child:?Row(

?????????mainAxisAlignment:?MainAxisAlignment.spaceEvenly,

?????????children:?<Widget>[

???????????_buildButtonColumn(color,?Icons.call,?'CALL'),

???????????_buildButtonColumn(color,?Icons.near_me,?'ROUTE'),

???????????_buildButtonColumn(color,?Icons.share,?'SHARE'),

?????????],

???????),

?????);

?????var?textSection?=?Container(

???????padding:?const?EdgeInsets.all(32),

???????child:?Text(

?????????'Lake?Oeschinen?lies?at?the?foot?of?the?Blüemlisalp?in?the?Bernese?'

?????????'Alps.?Situated?1,578?meters?above?sea?level,?it?is?one?of?the?'

?????????????'larger?Alpine?Lakes.?A?gondola?ride?from?Kandersteg,?followed?by?a?'

?????????????'half-hour?walk?through?pastures?and?pine?forest,?leads?you?to?the?'

?????????????'lake,?which?warms?to?20?degrees?Celsius?in?the?summer.?Activities?'

?????????????'enjoyed?here?include?rowing,?and?riding?the?summer?toboggan?run.',

?????????softWrap:?true,

???????),

?????);

????return?MaterialApp(

??????home:?Scaffold(

????????appBar:?AppBar(

??????????title:?Text('layout?demo'),

????????),

????????body:?ListView(

??????????children:?<Widget>[

????????????Image.asset(

??????????????'assets/images/food05.jpeg',

??????????????width:?600,

??????????????height:?200,

??????????????fit:?BoxFit.cover,

????????????),

????????????titleSection,

????????????bottonSection,

????????????textSection,

??????????],

????????),

??????),

????);

??}


??Column?_buildButtonColumn(Color?color,IconData?icon,?String?label)?{

????return?Column(

//??????mainAxisSize:?MainAxisSize.min,

//??????mainAxisAlignment:?MainAxisAlignment.center,

??????children:?<Widget>[

????????Icon(icon,color:?color,),

????????Container(

??????????child:?Text(label,style:?TextStyle(

????????????fontSize:?12,

????????????fontWeight:?FontWeight.w400,

????????????color:?color

??????????),),

????????),

??????],

????);

??}

}

添加調(diào)試

void?main()?{

??debugPaintSizeEnabled=true;

??runApp(MyApp());

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末篓足,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子厢拭,更是在濱河造成了極大的恐慌苗分,老刑警劉巖,帶你破解...
    沈念sama閱讀 219,188評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件择浊,死亡現(xiàn)場離奇詭異琢岩,居然都是意外死亡担孔,警方通過查閱死者的電腦和手機糕篇,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,464評論 3 395
  • 文/潘曉璐 我一進店門安券,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事盛龄∮嗖埃” “怎么了钟些?”我有些...
    開封第一講書人閱讀 165,562評論 0 356
  • 文/不壞的土叔 我叫張陵达传,是天一觀的道長蒙保。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么她紫? 我笑而不...
    開封第一講書人閱讀 58,893評論 1 295
  • 正文 為了忘掉前任贿讹,我火速辦了婚禮,結(jié)果婚禮上相叁,老公的妹妹穿的比我還像新娘。我一直安慰自己椿访,他們只是感情好荣病,可當我...
    茶點故事閱讀 67,917評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著颊亮,像睡著了一般柴梆。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上终惑,一...
    開封第一講書人閱讀 51,708評論 1 305
  • 那天绍在,我揣著相機與錄音,去河邊找鬼雹有。 笑死偿渡,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的霸奕。 我是一名探鬼主播溜宽,決...
    沈念sama閱讀 40,430評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼质帅!你這毒婦竟也來了适揉?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,342評論 0 276
  • 序言:老撾萬榮一對情侶失蹤煤惩,失蹤者是張志新(化名)和其女友劉穎嫉嘀,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體盟庞,經(jīng)...
    沈念sama閱讀 45,801評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡吃沪,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,976評論 3 337
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了什猖。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片票彪。...
    茶點故事閱讀 40,115評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡红淡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出降铸,到底是詐尸還是另有隱情在旱,我是刑警寧澤,帶...
    沈念sama閱讀 35,804評論 5 346
  • 正文 年R本政府宣布推掸,位于F島的核電站桶蝎,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏谅畅。R本人自食惡果不足惜登渣,卻給世界環(huán)境...
    茶點故事閱讀 41,458評論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望毡泻。 院中可真熱鬧胜茧,春花似錦、人聲如沸仇味。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,008評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽丹墨。三九已至廊遍,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間贩挣,已是汗流浹背喉前。 一陣腳步聲響...
    開封第一講書人閱讀 33,135評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留王财,地道東北人被饿。 一個月前我還...
    沈念sama閱讀 48,365評論 3 373
  • 正文 我出身青樓,卻偏偏與公主長得像搪搏,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子闪金,可洞房花燭夜當晚...
    茶點故事閱讀 45,055評論 2 355

推薦閱讀更多精彩內(nèi)容