Hello! I need your help!
- User
Hello! I need your help!
- Assistant
Sure, how can I assist you?
- User
- Assistant
Yes, the
_updateBall()method is responsible for updating the position and velocity of the bouncing ball based on the current time stamp. In order to use the_updateBall()method, you need to add aTickerthat will periodically call this method. Here's how you can modify theinitState()method to create aTickerand start it:AnimationController _controller; @override void initState() { super.initState(); _controller = AnimationController( vsync: this, duration: const Duration(days: 365), // set duration to a long value (1 year) )..addListener(() { _updateBall(_controller.lastElapsedDuration.inMilliseconds.toDouble()); }); _controller.forward(); }The
AnimationControlleris created withvsync: thiswhich defines theSingleTickerProviderStateMixinas the provider of the . The duration of the animation is set to a long value since we just want to update the ball continuously. The method is called when the ticks, and it calls the method with the elapsed time since the start of the animation. Finally, the method is called on the controller to start the animation. - User
Yes, it's much better now. Can you please remove animation? And it seems that bottom and top are reversed, cuz ball bouncing from the top:) Also, it will be great if scene with the ball would occupy all of the screen space. And I want ball to be faster 5 times.
- Assistant
- User
I believe that you did all that you mentioned, but I can't test it right now because app doesn't respond to user input:(
- Assistant
- User
I don't think the Key was an issue, you accidentally remove Ticker:)
- Assistant