Line data Source code
1 : import 'package:flutter/material.dart'; 2 : 3 : class AnimatedTranslateWidget extends AnimatedWidget { 4 : final AnimationController animationController; 5 : final Tween<double> opacity; 6 : final Tween<Offset> position; 7 : final Widget widget; 8 : final Curve positionCurve; 9 : final Curve opacityCurve; 10 : 11 3 : AnimatedTranslateWidget({ 12 : Key key, 13 : @required this.animationController, 14 : @required this.widget, 15 : this.opacity, 16 : this.position, 17 : this.positionCurve = Curves.ease, 18 : this.opacityCurve = Curves.ease, 19 3 : }) : super(key: key, listenable: animationController); 20 : 21 3 : @override 22 : Widget build(BuildContext context) { 23 3 : return FadeTransition( 24 3 : opacity: ((opacity?.begin != null && opacity?.end != null) 25 0 : ? opacity 26 3 : : Tween<double>(begin: 0, end: 1)) 27 3 : .animate( 28 3 : CurvedAnimation( 29 3 : parent: animationController, 30 3 : curve: opacityCurve, 31 : ), 32 : ), 33 3 : child: SlideTransition( 34 12 : position: ((position?.begin != null && position?.end != null) 35 3 : ? position 36 6 : : Tween<Offset>(begin: Offset(-1, 0), end: Offset(0, 0))) 37 3 : .animate( 38 3 : CurvedAnimation( 39 3 : parent: animationController, 40 3 : curve: positionCurve, 41 : ), 42 : ), 43 3 : child: widget, 44 : ), 45 : ); 46 : } 47 : }