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.

Building dynamic lists

Building dynamic lists

- [Instructor] Having a list of chat bubbles declared in this manner is also not very scalable. In reality, you do not know the number of chat messages for a particular user. So it could be five, 10, or 50. This is also duplicated code and hard to maintain, right? So we want a list view that can populate this widget X number of times. And for that we have something called ListView.builder. Let's comment this code out and create the ListView here. So the child will now take a ListView.builder and the property that is required is itemBuilder. So here it takes a call back which takes parameters context and index. And now you can return any widget that you like. So I will return the chat bubble itself. So let's un-comment this out and now this ListView.builder is going to return a chat bubble. Let's add a semicolon here. I have forgotten the return here. So let me add that as well. But this itemBuilder also needs a size,…

Contents