"type 'double' is not a subtype of type 'int' in type cast" error in flutter. What should i do?


enter image description here

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 {
  _HomePageState createState() => _HomePageState();
class _HomePageState extends State<HomePage>
    with SingleTickerProviderStateMixin {
  Animation animation;
  AnimationController animationController;
  void initState() {
    animationController =
        AnimationController(duration: Duration(seconds: 3), vsync: this);
    animation = Tween(begin: -1, end: 0).animate(CurvedAnimation(
        curve: Curves.fastOutSlowIn, parent: animationController));
  Widget build(BuildContext context) {
    final double width = MediaQuery.of(context).size.width;
    return AnimatedBuilder(
        animation: animationController,
        builder: (BuildContext context, Widget child) {
          return Scaffold(
            body: Transform(
                  Matrix4.translationValues(animation.value * width, 0, 0),
              child: Center(
                child: Text(
                  style: TextStyle(fontWeight: FontWeight.bold, fontSize: 50),


All you need is to explicitly state the type of your Tween to be double:

AnimationController(duration: Duration(seconds: 3), vsync: this);  
animation = Tween<double>(begin: -1, end: 0).animate(CurvedAnimation(curve: Curves.fastOutSlowIn, parent: animationController));

Recent Tips

  1. hiding the autocomplete list when user click outside the textbox is not working as expected
  2. JSF IceFaces basic problem with redisplaying input value
  3. How to validate material ui TextField in reactjs?
  4. Go and MongoDB connection won't work with panic log "no reachable server"
  5. WordPress Posts Pagination Not Working
  6. F# sprintf won't print in interactive console
  7. Spring Integration get FTP files recursively with outbound-gateway
  8. Jade mixins not getting working from external file
  9. Can not access defined exports from the webpack bundle?
  10. Completely new to Node.js - API Programming
  11. Formatting Compare-Object Ouput
  12. Add dynamically added textbox value from User Control to main form
  13. Create a ByteBuf in Netty 4.0
  14. Is it possible to do computation before super() in the constructor?
  15. Q-learning Updating Frequency
  16. Wrong reload order when using Gulp and browserSync
  17. I use hugo build static page. But don't have content
  18. How to change background color and set bar colors based on conditional formatting in VBA?
  19. Problem when comparing two numeric values in SAS
  20. Is ACE reactor timer managment thread safe?
  21. Why Express res.render dumps the render output (EJS template) in console?
  22. Define generic typescript sort function of a certain type
  23. Eclipse RCP: TableViewer setInput from another view
  24. Migrating data from RDBMS to Arango DB: Bulk upload
  25. How can I check the existence of a key/file on an Amazon S3 Bucket using AWS iOS SDK v2?
  26. Can exponentially long bitstrings be stored in (and retrieved from) qubits reliably?
  27. Django refuses to save the date shown on form
  28. Debug output mentions I should ask for Application Badge permission
  29. Scrapy - Trouble getting output from xpath/css
  30. PowerShell Skype for Business server side filtering on variable