Flutter之AspectRatio组件

/**
 * 强制子部件的宽度和高度具有给定的宽高比,可以父容器给定一个宽或者高,来换算另一个值
    const AspectRatio({
    Key key,
    @required this.aspectRatio,//宽高比
    Widget child
    })
 * */
body: Container(
            width: 100.0,
            child: AspectRatio(
              aspectRatio: 2.0 / 3.0,
              child: Container(
                color: Color(0xffff0000),
              ),
            ),
          )

猜你喜欢

转载自blog.csdn.net/weixin_34268753/article/details/86946944