PopAndScaleTransition<T> constructor
PopAndScaleTransition<T> ({
- required Widget page,
Implementation
PopAndScaleTransition({required this.page})
: super(
pageBuilder: (context, animation, secondaryAnimation) => page,
transitionsBuilder: (context, animation, secondaryAnimation, child) {
const begin = Offset(0.0, 1.0);
const end = Offset.zero;
const curve = Curves.easeInOut;
final tween =
Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
final offsetAnimation = animation.drive(tween);
const staggerDelay = 0.1;
final scaleValue = Tween<double>(
begin: 0.0,
end: 1.0,
).animate(CurvedAnimation(
parent: animation,
curve: const Interval(0.0, 1.0, curve: curve),
));
final staggerScaleValue = Tween<double>(
begin: 0.8,
end: 1.0,
).animate(CurvedAnimation(
parent: animation,
curve: const Interval(staggerDelay, 1.0, curve: curve),
));
return AnimatedBuilder(
animation: animation,
builder: (context, child) {
return Transform.scale(
scale: scaleValue.value * staggerScaleValue.value,
child: SlideTransition(
position: offsetAnimation,
child: child,
),
);
},
child: child,
);
},
);