Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Building Dynamic Lists in Flutter with ListViews

    nader dabitnader dabit
    flutterFlutter
    dartDart
    androidAndroid
    iosiOS

    ListView is the most commonly used scrolling widget in a Flutter application. In this video, we'll learn how to create dynamic lists using Flutter's ListView widget to render both lists of Strings & lists of Maps

    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    Instructor: 00:01 We'll begin with the basic material app with the home set to main app. Main app returns a scaffold containing an app bar and a body. In the body of this scaffold, we'd like to render a list of text widgets. We'll first define a variable of people and set it to a list.

    00:34 Next, we'll update the child of the center widget to be a listview.builder. Listview.builder builds the children of the list on demand. The builder constructor is appropriate for list views with a large, unknown, or infinite number of children because the builder is called only for those children that are actually visible.

    00:54 We'll first set the item count to the length of our list. The item builder method will be used to build the items within our list. The item builder method will be called the number of times set as the item count. In the item builder, we'll return a text widget set to the value of the index of the current item in the people array.

    01:34 Next, we'll look at how to render a list of maps. First, we'll update the items in our list to be of type map. Next, in the item builder function, we'll return the people index with the name property. We can also add padding to the list by setting a padding property.

    Discuss

    Discuss