Flutter之Container

1、Container介紹

我們先看它的構造方法

  Container({Key key,this.alignment,this.padding, //容器內補白,屬于decoration的裝飾范圍Color color, // 背景色Decoration decoration, // 背景裝飾Decoration foregroundDecoration, //前景裝飾double width,//容器的寬度double height, //容器的高度BoxConstraints constraints, //容器大小的限制條件this.margin,//容器外補白,不屬于decoration的裝飾范圍this.transform, //變換this.child,this.clipBehavior = Clip.none,})

Container是一個組合類容器,它本身不對應具體的RenderObject,它是DecoratedBox、ConstrainedBox、Transform、Padding、Align等組件組合的一個多功能容器,所以我們只需通過一個Container組件可以實現同時需要裝飾、變換、限制的場景

?

?

?

?

?

?

?

?

2、代碼測試

代碼測試1、

  @overrideWidget build(BuildContext context) {return MaterialApp(title: 'open url',home: Scaffold(appBar: AppBar(title: Text('hello flutter'),),body: Container(margin: EdgeInsets.only(top: 50, left: 50),constraints: BoxConstraints.tightFor(width: 200, height: 150),decoration: BoxDecoration(gradient: RadialGradient( //背景徑向漸變colors: [Colors.red, Colors.orange],center: Alignment.topLeft,radius: .98),borderRadius:BorderRadius.all(Radius.circular(5)),boxShadow: [ //卡片陰影BoxShadow(color: Colors.black54,offset: Offset(2.0, 2.0),blurRadius: 4.0)]),alignment: Alignment.center,child: Text("chenyu", style: TextStyle(color: Colors.white, fontSize: 40.0)),),),);}

代碼測試2、

    @overrideWidget build(BuildContext context) {return MaterialApp(title: 'open url',home: Scaffold(appBar: AppBar(title: Text('hello flutter'),),body: Padding(padding: EdgeInsets.all(30),child: DecoratedBox(decoration: BoxDecoration(color: Colors.blue),child: Text("chenyu", style: TextStyle(color: Colors.white, fontSize: 40.0)),),)),);}

代碼測試3、

    @overrideWidget build(BuildContext context) {return MaterialApp(title: 'open url',home: Scaffold(appBar: AppBar(title: Text('hello flutter'),),body: DecoratedBox(decoration: BoxDecoration(color: Colors.blue),child: Padding(padding: EdgeInsets.all(40),child: Text("chenyu", style: TextStyle(color: Colors.white, fontSize: 40.0)),),),),);}

代碼測試4、

  @overrideWidget build(BuildContext context) {return MaterialApp(title: 'open url',home: Scaffold(appBar: AppBar(title: Text('hello flutter'),),body: Column(mainAxisSize: MainAxisSize.min,children: <Widget>[Text("chenyu1"),Text("chenyu2"),Container(margin: EdgeInsets.all(20),color: Colors.red,child: Text("chenyu3", style: TextStyle(fontSize: 40, color: Colors.white)),),Container(padding: EdgeInsets.all(20),color: Colors.red,child: Text("chenyu4", style: TextStyle(fontSize: 40, color: Colors.white)),),],),),);}

?

?

?

?

?

?

?

?

3、運行結果

?

?

?

?

?

?

?

4、總結

Container(margin: EdgeInsets.all(20.0), //容器外補白color: Colors.orange,child: Text("Hello world!"),
),
Container(padding: EdgeInsets.all(20.0), //容器內補白color: Colors.orange,child: Text("Hello world!"),
),

等價下面的代碼

Padding(padding: EdgeInsets.all(20.0),child: DecoratedBox(decoration: BoxDecoration(color: Colors.orange),child: Text("Hello world!"),),
),
DecoratedBox(decoration: BoxDecoration(color: Colors.orange),child: Padding(padding: const EdgeInsets.all(20.0),child: Text("Hello world!"),),
),

?

?

?

?

?

?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/286914.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/286914.shtml
英文地址,請注明出處:http://en.pswp.cn/news/286914.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

關于jQuery.query.js 取參數的一個小問題

形如&#xff1a;http://localhost:10864/srch.htm?keys&type1 這樣的地址&#xff0c;如果我們要取keys的參數&#xff1a; var srchKey $.query.get("keys"); 那么得到的將是‘true’ &#xff0c;而不是空客串&#xff0c;這常常不是我們想要的 。 修正辦法…

安卓模擬器獲取服務器信息出錯,安卓模擬器客戶端與服務器不同步

安卓模擬器客戶端與服務器不同步 內容精選換一換目前從本地或虛擬機通過DRS備份遷移功能直接遷移到本云RDS for SQL Server實例上&#xff0c;在遷移完成后還需要針對Login賬號&#xff0c;DBLink&#xff0c;AgentJOB&#xff0c;關鍵配置進行識別&#xff0c;并手動完成相關同…

Blazor University (24)路由 —— 可選路由參數

原文鏈接&#xff1a;https://blazor-university.com/routing/optional-route-parameters/可選路由參數Blazor 不明確支持可選路由參數&#xff0c;但可以通過在組件上添加多個 page 聲明輕松實現等效。例如&#xff0c;更改標準 Counter.razor 頁面以添加額外的 URL。page &qu…

【無人機組裝與調試】第六章 電調、電池、電機

【無人機組裝與調試】系列課程全集: 第一章 概述 第二章 關于新西達30A電調說明書的問題 第三章 舵機安裝與調整 第四章 F450四軸裝機實例-選擇機型、需要的器材工具材料 第五章 無人機遙控器 第六章 電調、電池、電機 一、電調 6.1.1 電調的概念 電調,全稱電子調速器,英…

關于tomcat和sessionCookieName和SESSION_PARAMETER_NAME以及disableURLRewriting參數原理和使用...

關于tomcat和sessionCookieName和SESSION_PARAMETER_NAME以及disableURLRewriting參數 關于session和cookie參考&#xff1a; http://www.blogjava.net/freeman1984/archive/2011/09/02/357833.html http://www.blogjava.net/freeman1984/archive/2010/09/09/331501.html http:…

我讓代碼生了個孩子繼承了他爸爸誰知他爸爸繼承了他爺爺(16)

本系列文章將會以通俗易懂的對話方式進行教學&#xff0c;對話中將涵蓋了新手在學習中的一般問題。此系列將會持續更新&#xff0c;包括別的語言以及實戰都將使用對話的方式進行教學&#xff0c;基礎編程語言教學適用于零基礎小白&#xff0c;之后實戰課程也將會逐步更新。 若…

linux之lrzsz

1、lrzsz介紹 我們利用lrzsz進行windows和linux間的文件上傳下載 2、安裝 在ubuntu系統下 sudo apt-get install lrzsz 在centos系統下 yum install lrzsz 3、使用 1)、windows上傳文件到linux環境,使用如下命令 rz

POJ 1611 The Suspects (并查集)

The Suspects題目鏈接&#xff1a; http://acm.hust.edu.cn/vjudge/contest/123393#problem/B Description 嚴重急性呼吸系統綜合癥( SARS), 一種原因不明的非典型性肺炎,從2003年3月中旬開始被認為是全球威脅。為了減少傳播給別人的機會, 最好的策略是隔離可能的患者。 在Not-…

Android幀緩沖區(Frame Buffer)硬件抽象層(HAL)模塊Gralloc的實現原理分析(2)...

函數load也是實現在文件hardware/libhardware/hardware.c文件中&#xff0c;如下所示&#xff1a; static int load(const char *id, const char *path, const struct hw_module_t **pHmi) { int status; void *handle; struct hw_module_t …

Win8消費者預覽版下載地址 包含中文下載地址及中文手冊

Win8消費者預覽版下載地址&#xff08;32位英文版&#xff09;&#xff1a; http://ak.or.esd.microsoft.com/pr/WCPDL/8A9D4FDFF736C5B1DBF956B89D6C8FDFD925DACD2/Windows8-ConsumerPreview-32bit-English-x1794225.esd Win8消費者預覽版下載地址&#xff08;64位英文版&…

VS2019社區版(Community)試用30天過期的有效解決辦法

VS2019社區版是免費的&#xff0c;前提是你得登陸自己的賬戶&#xff0c;如果一開始安裝時沒有登陸&#xff0c;那么就會只有30天有效期。此時&#xff0c;需要我們登陸微軟賬號&#xff0c;重新驗證即可。 登陸微軟賬號&#xff0c;即可繼續免費試用。

【萬字長文】使用 LSM Tree 思想實現一個 KV 數據庫

目錄設計思路內存表WALSSTable 的結構SSTable 元素和索引的結構SSTable Tree內存中的 SSTable數據查找過程何為 LSM-Treee參考資料整體結構實現過程文件壓縮測試插入測試加載測試查找測試SSTable 結構SSTable 文件結構SSTable Tree 結構和管理 SSTable 文件讀取 SSTable 文件SS…

linux之安裝mysql提示Error: Unable to find a match: mysql-community-server

1 問題 在centos系統下安裝mysql,命令如下 yum -y install mysql-community-server 提示錯誤如下 [root@iZm5e6dk6exl71zbx327zvZ mysql]# yum -y install mysql-community-server MySQL Connectors Community …

記錄部件中GetFieldControlByFieldName(字段值樣式設置)用法

度量快速開發平臺中&#xff0c;記錄部件上&#xff0c;不單是字段名稱可以設置樣式&#xff0c;要填入內容的方框也可以設置樣式。通過獲取記錄部件上某一個字段的輸入控件&#xff0c;在二次開發中不常用。該方法只有一個參數&#xff0c;即要獲取對象的字段&#xff0c;需要…

C/C++/Linux工程師學習資料干貨路線這都有,從入門到實戰!【CSDN寶藏資料圖鑒第二期】

若是大一學子或者是真心想學習剛入門的小伙伴可以私聊我&#xff0c;若你是真心學習可以送你書籍&#xff0c;指導你學習&#xff0c;給予你目標方向的學習路線&#xff0c;無套路&#xff0c;博客為證。 前言 CSDN 是全球知名的開發者社區&#xff0c;創建于1999年&#xff…

你要的來了:ArcGIS空間插值分析方法權威解讀

插值問題的提出??? 一、趨勢面 Trend is a global polynomial interpolation that fits a smooth surface defined by a mathematical function (a

Socket解決粘包問題2

在AsynServer中對接收函數增加接收判斷&#xff0c;如果收到客戶端發送的請求信息&#xff0c;則發送10個測試包給發送端&#xff0c;否則繼續接收&#xff0c;修改后的接收代碼如下&#xff1a; private void AsynReceive(){byte[] data new byte[1024];//接收緩存string rec…

C# WebBrowser 取 window.open 新窗口 url的方法

System.Windows.Forms.WebBrowser wb; //WebBrowser 對象wb.NewWindow new CancelEventHandler(wb_NewWindow);wb.DocumentCompleted delegate{ #region 處理window.open新開窗口的問題System.Windows.Forms.HtmlElement html wb.Document.CreateElemen…

linux之rpm

1、rpm Linux rpm 命令用于管理套件 -a  查詢所有套件。-b<完成階段><套件檔>+或-t <完成階段><套件檔>+  設置包裝套件的完成階段,并指定套件檔的文件名稱。-c  只列出組態配置文件,本參數需配合"-l"參數使用。-d  只列出文本文件,…

保姆級的HTML零基礎教程少見吧?這是第一節(1)

作者簡介 作者名&#xff1a;1_bit 簡介&#xff1a;CSDN博客專家&#xff0c;2020年博客之星TOP5&#xff0c;藍橋簽約作者。15-16年曾在網上直播&#xff0c;帶領一批程序小白走上程序員之路。歡迎各位小白加我咨詢我相關信息&#xff0c;迷茫的你會找到答案。 目錄 HTML基…