Skip to main content

TweenAnimationBuilder

caution

⚠️ NOT shows animation on ↷ back button

TweenAnimationBuilder<double>(..) only makes animation when the Widet is built i.e. TweenAnimationBuilder<double>(..) does NOT show animation on ↷ back button

class ShoeDetailsScreen extends StatelessWidget {

Axis _axis = Axis.horizontal; // to check for axis here ,i.e. for different Offset in Transform


Widget build(BuildContext context) {
return CupertinoPageScaffold(
child: Center(

child: TweenAnimationBuilder<double>(
tween: Tween<double>(begin: 1, end: 0),
duration: const Duration(milliseconds: 1000),
curve: Curves.easeInOutBack,
builder: (context, value, child) {
return Transform.translate(
offset: axis == Axis.horizontal // if `horizontal [x=0]` else `vertical [y=0]`
? Offset(value * 145, 0.0) // Offset(x-axis, y-axis)
: Offset(
0.0,
value * 145, // value is in the builder of Tween...
),
child: Container(
height: 160,
width: 160,
color: Colors.green,
child: const Text('Center'),
),
);
},
),

),
);
}
}