I am doing a simple Curves Animation in flutter, but i am always getting an error like this "type 'double' is not a subtype of type 'int' in type cast" , what error i have made here?
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage>
with SingleTickerProviderStateMixin {
Animation animation;
AnimationController animationController;
@override
void initState() {
super.initState();
animationController =
AnimationController(duration: Duration(seconds: 3), vsync: this);
animation = Tween(begin: -1, end: 0).animate(CurvedAnimation(
curve: Curves.fastOutSlowIn, parent: animationController));
}
@override
Widget build(BuildContext context) {
final double width = MediaQuery.of(context).size.width;
animationController.forward();
return AnimatedBuilder(
animation: animationController,
builder: (BuildContext context, Widget child) {
return Scaffold(
body: Transform(
transform:
Matrix4.translationValues(animation.value * width, 0, 0),
child: Center(
child: Text(
"Welcome",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 50),
),
),
),
);
});
}
}