flutter UI 布局二三事情

flutter Align 与 Center

2020-04-23  本文已影响0人  bigCatloveFish

1,flutter 中的align 接受三个参数

    alignment,
    widthFactor,
    heightFactor,
 static const Alignment center = Alignment(0.0, 0.0); 中心点为 0, 0

2,flutter 中的align 的用法

1,一个宽度高度为10的方块 。
2,父视图的宽度为子试图宽度的 3 倍。 高度为子试图的8倍。
3,子视图在父视图的中点。


WeChat51d463cac8dd9d714297b27b3b6f470a.png WeChat8f6635d21aab2f843a7d8c3a40b8a474.png

2,flutter 中的center

center 继承自aligin 因为aligin 的alignment 默认为 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 是一个 不能设置 alignment的aligin。

上一篇下一篇

猜你喜欢

热点阅读