Life of a Widget?! | Decoding Flutter

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

tl;dr : Don't worry about performance, Flutter does magic.

👍︎︎ 2 👤︎︎ u/ChristianKl 📅︎︎ May 05 2021 🗫︎ replies
👍︎︎ 1 👤︎︎ u/scorr204 📅︎︎ May 04 2021 🗫︎ replies
Captions
[MUSIC PLAYING] ANDREW FITZ GIBBON: Coming to Flutter from another system, like Android or iOS, it's tempting to map what you already know about activities or view controllers onto widgets. Those things have life cycles, and widgets are the closest analog in Flutter. So they have life cycles too, right? Well, not really. To understand more, ask yourself, what is a widget exactly? And to understand how widgets are different, let's take a step back and consider what widgets actually are and how they fit into the Flutter framework. Consider an analogy. Let's say you want to bake a fancy multi-layer cake with different flavors throughout and a unique homemade frosting on top. You probably don't just bake this cake. Instead, you follow a set of instructions specific to each and every component. These recipes, even if you wrote them yourself, don't change while you're in the middle of making the cake. After it's done and after you've sampled a piece, you might decide that the frosting isn't quite right. And so you go and tweak the recipe for it, adding more sugar. And there's nothing you can do about the current frosting, but the next time you bake the cake, the frosting will be a bit sweeter. Your Flutter app is kind of like the cake. And the widgets are kind of like the recipes for the frosting, the batter, or the decorations. Just as you would use the recipe to create a cake, Flutter will use the widgets to determine what to draw on the screen. You can't change an existing cake into a different one by modifying the recipe after baking it without some timey, wimey, wobbly stuff. But in the same way, Flutter widgets are immutable. Once they're created they can't be changed. But an app has to respond to events, like user-input or animations. And so there must be some way of changing the widgets, right? Flutter handles this by rebaking whole parts of the cake. When your app needs change, it gives Flutter a new set of widgets. This might sound like a lot of work, but Flutter is designed to handle updates to the widgetry very efficiently. Behind the scenes elements and render objects keep track of where the widget is in relation to other widgets, whether things need to be rebuilt based on state, and updating the screen as needed. So does your widget have a life cycle? Not really, your app either needs that recipe or not. And so the widget is either built, rebuilt, or not used at all. For more on widgets and the rest of Flutter's internal architecture, head on over to flutter.dev. [MUSIC PLAYING]
Info
Channel: Flutter
Views: 51,053
Rating: undefined out of 5
Keywords: GDS: Yes, What’s a widget, widgets 101, widgets crash course, widgets for beginners, intro to widgets, widget lifecycles, how widgets work, what are Flutter widgets, developer shows, developer tutorials, Flutter, Flutter tutorials, Flutter developers, flutter app development, Flutter course, how Flutter works, Flutter best practices, Decoding Flutter, Google developers, flutter 101, get started with flutter, flutter apps, flutter widgets, build apps with flutter
Id: cyFM2emjbQ8
Channel Id: undefined
Length: 2min 59sec (179 seconds)
Published: Tue May 04 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.