Fit the rotated image to the screen in Flutter

1.1k Views Asked by At

Is there a way in Flutter to get a rotated image that fits the entire screen with no empty corners and without zooming the image (possibly using only repetition)?

This is the current code:

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

1

There are 1 best solutions below

0
On

use RotatedBox instead of Transform.rotate()