Instantly share code, notes, and snippets.

Embed
What would you like to do?
class _PriceTabState extends State<PriceTab> with TickerProviderStateMixin {
final double _initialPlanePaddingBottom = 16.0;
final double _minPlanePaddingTop = 16.0;
AnimationController _planeSizeAnimationController;
AnimationController _planeTravelController;
Animation _planeSizeAnimation;
Animation _planeTravelAnimation;
double get _planeTopPadding =>
_minPlanePaddingTop +
(1 - _planeTravelAnimation.value) * _maxPlaneTopPadding;
double get _maxPlaneTopPadding =>
widget.height - _initialPlanePaddingBottom - _planeSize;
double get _planeSize => _planeSizeAnimation.value;
@override
void initState() {
super.initState();
_initSizeAnimations();
_initPlaneTravelAnimations();
_planeSizeAnimationController.forward();
}
Widget _buildPlane() {
return AnimatedBuilder(
animation: _planeTravelAnimation,
child: Column(
children: <Widget>[
AnimatedPlaneIcon(animation: _planeSizeAnimation),
],
),
builder: (context, child) => Positioned(
top: _planeTopPadding,
child: child,
),
);
}
_initSizeAnimations() {
_planeSizeAnimationController = AnimationController(
duration: const Duration(milliseconds: 340),
vsync: this,
)..addStatusListener((status) {
if (status == AnimationStatus.completed) {
Future.delayed(Duration(milliseconds: 500),
() => _planeTravelController.forward());
}
});
[...]
}
_initPlaneTravelAnimations() {
_planeTravelController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 400),
);
_planeTravelAnimation = CurvedAnimation(
parent: _planeTravelController,
curve: Curves.fastOutSlowIn,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment