Summary

In this chapter, you've built a simple game, based on animation and on detecting a user's gestures.

Animations in Flutter are fast and relatively easy to implement. The moving parts involved in the animation are the Animation class, which takes in some values and translates them into animations, AnimationController, which controls the animation objects, Tween, which contains the value of the property that needs to change during the animation, and Ticker, which calls its callback once per animation frame.

Enclosing any widget in a GestureDetector will allow you to listen to several gestures the user performs over your user interface. This allowed a moving bat to be constructed on the screen, leveraging the onHorizontalDragUpdate property of GestureDetector.

Adding some randomness generally makes a game more interesting. We've also seen how to use the Random class to generate a random integer value with the nextInt method.

While building the game, you've also seen how to use LayoutBuilder to get the available space on a screen, and a Stack to control exactly how widgets should be positioned on the screen of your app.

To give some feedback to the user, and have them perform a choice, you've also used an AlertDialog, setting its title, content, and actions.

In the next chapter, we'll create a movies app that will connect to a web service using the HTTP library service.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.121.8