I have a Container
with a child that I want to rotate. When rotating, I want the size of the Container
to match the new borders of the child.
Let’s say I have the following setup:
Container(
margin: EdgeInsets.all(200),
child: Stack(
children: [
IntrinsicHeight(
child: Container(
color: Colors.green,
child: Transform.rotate(
angle: 45 * 3.14 / 180,
child: Container(
color: Colors.amber,
child: Text("Whatever"),
)
),
),
),
],
),
),
This gives the following output:
My desired output is:
So that the Container
matches the acutal dimentions of the rotated child. How can I achieve this?
I thought IntrinsicHeight
would do the trick but it doesn’t seem to care about rotation. I also tried rotating with RotationTransition
, but that didn’t work either