Unity_UIWidgets学习笔记03_组件_Container
生活随笔
收集整理的這篇文章主要介紹了
Unity_UIWidgets学习笔记03_组件_Container
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、源碼
public Container(Key key = null,//唯一標識符Alignment alignment = null,//子元素的排列方式EdgeInsets padding = null,//內邊距Color color = null,//顏色,Decoration decoration = null,//繪制在child后面的裝飾,設置了decoration的話,就不能設置color屬性,否則會報錯,此時應該在decoration中進行顏色的設置。Decoration forgroundDecoration = null,//繪制在child前面的裝飾。float? width = null,//container的寬度float? height = null,//container的高度BoxConstraints constraints = null,//添加到child上額外的約束條件EdgeInsets margin = null,//外邊距Matrix3 transfrom = null,//變換矩陣Widget child = null//子元素)2、例子
new Container(constraints:BoxConstraints.expand(height:Theme.of(context).textTheme.display1.fontSize*1.1f+200f),decoration:new BoxDecoration(border: Border.all(width: 2.0f, color: Colors.red),color: Colors.grey,borderRadius: BorderRadius.all(Radius.circular(20.0f)),image:new DecorationImage(image:new NetworkImage(@"https://hbimg.huabanimg.com/437658f08a68e1d24ea512b48b4a8cb7d808f3de25148-uBjU7Q_fw658"),centerSlice: Unity.UIWidgets.ui.Rect.fromLTRB(270.0f, 180.0f, 1360.0f, 730.0f))),alignment:Alignment.center,padding:EdgeInsets.all(8),margin:EdgeInsets.all(10f),// color:Colors.green,child:new Text("Hello World",style:Theme.of(context).textTheme.display1.copyWith(color:Colors.black)),transfrom:Matrix3.makeRotate(0.3f));3,簡單使用
按鈕的狀態(正常態、點擊態)的顏色變化;
new GestureDetector(child:new Container(constraints:BoxConstraints.expand(height:Theme.of(context).textTheme.display1.fontSize*1.1f+200f),decoration:new BoxDecoration(border: Border.all(width: 2.0f, color: Colors.red),color: btnColor,borderRadius: BorderRadius.all(Radius.circular(80.0f))),alignment:Alignment.center,padding:EdgeInsets.all(20),margin:EdgeInsets.only(top:350),// color:Colors.green,child:new Text("按鈕",style:Theme.of(context).textTheme.display1.copyWith(color:Colors.black))),onTapDown:(x)=>{setState(()=>{btnColor=Colors.blue;});},onTapUp:(x)=>{setState(()=>{btnColor=Colors.grey;});});?
轉載于:https://www.cnblogs.com/PandaHome/p/11108439.html
總結
以上是生活随笔為你收集整理的Unity_UIWidgets学习笔记03_组件_Container的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 验证能有多优雅
- 下一篇: check_mk自定义监控实践之powe