E.2. What’s the paradigm or mental model difference?

The biggest difference between writing a Flutter app and an Android one is that Flutter uses composition and reactive-style programming to make handling your UI state simple. You, the developer, don’t have to be concerned with mutating the UI state because it’s handled by the framework internally. This is mostly due to the fact that the UI is described by widgets.

Widgets aren’t UI elements themselves, but rather they’re blueprints for true elements. And you use widgets to describe the current view. As your app’s state changes, and the screen needs to re-render, the framework is just rendering the current widget tree, and it knows how to transition the UI as it changes.

You don’t have to tell the UI explicitly to remove elements from the screen and add new ones. You just say, “Hey Flutter, this is what my widget tree looks like. And, when that button is pressed, it’ll look like this.” Flutter knows how to make that transition happen. This is called reactive programming.

Secondly, in Android, you often extend or subclass View to create your views. Flutter uses composition instead. All of your widgets are tiny, modular views that are pieced together, similar to a markup language like HTML. This makes your views highly reusable.

Note

Composition is discussed quite a bit in chapter 2.

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

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