flutter / dart 筆記:用 center 與 container 排列物件

單一物件排列方法

使用 center 排列物件

//建立 appBody 物件
var appBody = Center(
  child: hiFlutter,
  heightFactor: 2,     //Center物件 是 Text物件 的 2 倍高
  widthFactor: 1.5,    //Center物件 是 Text物件 的 1.5 倍寬



使用 Container 排列物件

//建立 appBody物件
var appBody = Container(   //把 Center 換成 Container
  child: hiFlutter,
  alignment: Alignment.topCenter,    //對齊中央上方
  margin: EdgeInsets.all(50.0),      //EdgeInsets 設定距離方法一
  color: Colors.white,
  padding: EdgeInsets.FromLTRB(30, 30, 30, 30),    //EdgeInsets 設定距離方法二
  //transform: Matrix4.rotationZ(0.1),    //Container 沿Z軸旋轉0.1個徑度
  //transform: Matrix4.translationValues(30, 0, 0)  //x, y, z 軸的移動距離
)