flutter Align 與 Center

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。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容