Here is what I’m trying to achieve and had achieved by using Positioned
instead of SlideTransition
before attempting to do animations:
Now when I tried using SlideTransition
and after messing around with the fits a little I got this:
How can I make the image not get cropped at the top and bottom where it would be meeting the constraints of its parent container?
Container(
color: Colors.yellow,
width: 300,
height: 400,
child: Stack(
fit: StackFit.passthrough,
children: [
SlideTransition(
position: _offsetAnimation,
child: Transform.rotate(
angle: pi / 4,
child: Image.asset('assets/TOD10N_v.png', height: screenHeight, fit: BoxFit.cover)
)
),
],
)
)
2
Answers
You need to use
clipBehaviour = Clip.none
on the stack, and put the stack child in aPositioned
widget with any propertytop, right, bottom, left
set to anything.Place it in a
FittedBox
widgethttps://api.flutter.dev/flutter/widgets/FittedBox-class.html