简体   繁体   中英

ListTile Flutter

is there any way I can add more value to the ListTile in the code as I am trying to use ListTile to call the value of data in FireCloud. As for now, I can only call 2 of the data that is in the document. Any help would be much appreciated on how to call multiple data in FireCloud and display it.

    return Container(
     child: Card(
      child: ListTile(
       title: Text(widget.post.data["Address"]),
        subtitle: Image.network(widget.post.data["Picture"], 
     ),
   ),
 ),
);

Use ListView.builder constructor , this will help you fetch the total data from the FireCloud . You can use it like this:

Two major things required, these are:

  • itemCount: Keeps the count of the data you are going to fetch from the FireCloud . Store the coming data into a list, and then pass it into this key
  • itemBuilder: Builds your view which will have the data used from the passed item in the itemCount

Reference:

ListView.builder(
  itemCount: listItems.length,
  itemBuilder: (BuildContext ctxt, int index){
    // your_view
  }
)

For more reference, please refer to this Medium Article on how to get started: Flutter: Displaying Content using ListView.builder

Check out this example that will work for you :

 ListView.builder(
            itemCount: /* snapshot.data.length */,
            itemBuilder: (_, index) {
              return  GestureDetector(
                onTap: (){
                  //navigateToDetail(snapshot.data[index]),
                },
                              child: Card(
                  child: Column(
                    children: <Widget>[
                     Text('your address'),
                     Text('you and another data')

                    ],
                  ),
                ),
              );
          }),

You ca align it in the way you want.

Let me know if it works

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM