【问题标题】:Fit the rotated image to the screen in Flutter在 Flutter 中使旋转后的图像适合屏幕
【发布时间】:2021-01-19 13:04:33
【问题描述】:

Flutter 中有没有办法获得适合整个屏幕的旋转图像,没有空角且不缩放图像(可能只使用重复)?

这是当前代码:

Widget build(BuildContext context) {
    Size size = MediaQuery.of(context).size;

    return Container(
        width: size.width,
        height: size.height,
        decoration: BoxDecoration(
            gradient: LinearGradient(
                begin: Alignment.bottomCenter,
                end: Alignment.topCenter,
                colors: [
                    Colors.black,
                    Colors.blue
                ],
            ),
        ),
        child: Stack(
            alignment: Alignment.center,
            children: <Widget>[
                Opacity(
                    opacity: 0.15,
                    child: Transform.rotate(
                        angle: -0.45,
                        child: Image(
                            image: AssetImage("assets/images/food.png"),
                            repeat: ImageRepeat.repeat,
                        ),
                    ),
                ),
                Text(
                    "test",
                    style: TextStyle(
                        fontSize: 100,
                        color: Colors.white,
                    ),
                ),
            ],
        ),
    );
}

the result

【问题讨论】:

    标签: image flutter background rotatetransform


    【解决方案1】:

    使用RotatedBox 代替Transform.rotate()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-09
      • 2017-03-22
      • 2011-05-12
      • 2018-09-12
      • 2013-04-11
      • 2018-04-24
      • 2011-03-22
      相关资源
      最近更新 更多