Breaking your code into reusable custom widgets allows you to save time and effort by letting your app use your widgets in multiple areas.
which is how we're able to use our reusable card … to style each of them, … and have them laid out using our expanded widgets, … but their content are all different. … And usually in Flutter, … when we're using the widgets that Flutter have created, … they tend to address this by having a child property. … because we're getting an error that tells us, … the final variable cardChild must be initialized, … so we do that in here. … Now, I don't think the child property should be required, … so we don't need to add the required annotation. … All we need to do is just write this.cardChild. … So that means if we create a new reusable card, … then we can if we wish to add a child … to go inside our widget. … But if we don't need to have any content, … then we can just simply have it as is. … Now the final thing is, … where is this child going to be placed inside our widget tree? … Well, it's going to be a child of our container. … So we're going to tap into the container's child property, … and we're going to say that whatever cardChild …
This course was created by London App Brewery. We are pleased to host this content in our library.
- Using Flutter themes
- Refactoring widgets
- Customizing widgets using themes
- Routes and navigating
- Dart maps