From the course: Flutter Essential Training: Build for Multiple Platforms
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Creating your own custom widget - Flutter Tutorial
From the course: Flutter Essential Training: Build for Multiple Platforms
Creating your own custom widget
- [Instructor] At this point, we have a number of chat bubbles elements built under this list view. And that is pretty great progress for you already. However, as a software engineer, do you think this is a maintainable or readable way of building this part of the UI? We are constantly duplicating code for doing the same thing, just with minor differences. Also, it is not so maintainable as well, because if I make a change in this child, like making this too black, I will have to redo that modification in every child here. This is more prone to human errors. So can we extract this out as a different function with parameters that return a widget, and then we can call that function directly here and make the code more readable? Let's try it out. I'm copying this out, and let's create a method here called getChatBubble, which takes an alignment and a message. It will return a widget. So here, you can return the entire…
Contents
-
-
-
-
-
Flutter building blocks to know about11m 7s
-
(Locked)
Building basic widgets for the login screen23m 38s
-
(Locked)
Building basic widgets for the chat screen17m 26s
-
(Locked)
Placements and alignments12m 36s
-
(Locked)
Structure: Flexible and expanded6m 17s
-
(Locked)
Creating your own custom widget6m 13s
-
(Locked)
Building dynamic lists3m 34s
-
(Locked)
How to breakdown designs into code?3m 11s
-
(Locked)
Breaking down designs: More examples3m 14s
-
-
-
-
-
-