Flutter-最簡單的 Align 使用範例

背景知識

有使用到 Container 可參考Flutter-最簡單的 Container 使用範例

官方說明頁面

本文 source code

介紹內容

給予 widget 對齊方式,支援左上(topLeft)、上中(topCenter)、上右(topRight)、左中(centerLeft)、中心(center)、中右(centerRight)、下左(bottomLeft)、下中(bottomCenter)、下右(bottomRight)

使用方法

使用 Align 包裹一個 Container , 預設為 center 所以顯示如下圖

Align(
      child: Container(
        width: 100,
        height: 100,
        color: Colors.red,
      ),
    );

下面測試其他格式

topLefttopCentertopRight
centerLeftcentercenterRight
bottomLeftbottomCenterbottomRight

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *