Flutter Layout Widget之AspectRatio

AspectRatio

是一个widget,将子widget的大小指定为某个特定的宽高比

定义

 const AspectRatio({
    Key key,
    @required this.aspectRatio,
    Widget child
  })
  • aspectRatio → double 宽高比
new Container(
      color: Colors.grey,
      alignment: Alignment.center,
      width: 200.0,
      height: 200.0,
      child: new AspectRatio(
        aspectRatio: 2,
        child: new Container(
          color: Colors.red,
        ),
      ),
    )

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/lmjssjj/article/details/84959022
今日推荐