1,flutter 中的align 接受三個(gè)參數(shù)
alignment,
widthFactor,
heightFactor,
- alignment 是一個(gè) Alignment 類 。Alignment( ,y) , x 與 y 均為 -1 到 1的 值。
static const Alignment center = Alignment(0.0, 0.0); 中心點(diǎn)為 0, 0
- widthFactor 與 heightFactor 這倆值的作用是計(jì)算align的大小。默認(rèn)是 1。這倆值在文檔上 寫的是
正數(shù)即可。
2,flutter 中的align 的用法
1,一個(gè)寬度高度為10的方塊 。
2,父視圖的寬度為子試圖寬度的 3 倍。 高度為子試圖的8倍。
3,子視圖在父視圖的中點(diǎn)。

WeChat51d463cac8dd9d714297b27b3b6f470a.png

WeChat8f6635d21aab2f843a7d8c3a40b8a474.png
2,flutter 中的center
center 繼承自aligin 因?yàn)閍ligin 的alignment 默認(rèn)為 Alignment.center 于是
class Center extends Align {
/// Creates a widget that centers its child.
const Center({ Key key, double widthFactor, double heightFactor, Widget child })
: super(key: key, widthFactor: widthFactor, heightFactor: heightFactor, child: child);
}
center 是一個(gè) 不能設(shè)置 alignment的aligin。