简体   繁体   English

ListTile Flutter

[英]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.当我尝试使用 ListTile 调用 FireCloud 中的数据值时,有什么方法可以为代码中的 ListTile 添加更多值。 As for now, I can only call 2 of the data that is in the document.至于现在,我只能调用文档中的 2 个数据。 Any help would be much appreciated on how to call multiple data in FireCloud and display it.关于如何在 FireCloud 中调用多个数据并显示它的任何帮助将不胜感激。

    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 .使用ListView.builder 构造函数,这将帮助您从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 . itemCount:保留您要从FireCloud获取的数据的计数。 Store the coming data into a list, and then pass it into this key将传入的数据存入一个列表,然后传入这个key
  • itemBuilder: Builds your view which will have the data used from the passed item in the itemCount itemBuilder:构建您的视图,该视图将使用itemCount传递的项目的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如需更多参考,请参阅这篇关于如何开始的 Medium 文章: 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让我知道它是否有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 条件语句不适用于 ListTile onTap Flutter - Conditional statement not working on ListTile onTap Flutter firestore 数据未显示在 Flutter listtile ListView 中 - firestore data not displaying in Flutter listtile ListView 从 ListTile Flutter 更新 Firestore 文档 Boolean 值 - Updating Firestore Document Boolean value from ListTile Flutter Flutter - 如何使用 ListTile 显示从 Firebase Firestore 中提取的 ArrayList 项? - Flutter - How to show ArrayList items pulled from Firebase Firestore with ListTile? Flutter/Firestore:如何在 ListTile 中显示来自 doc 的数据? - Flutter/Firestore : How do I display data from doc in a ListTile? 无法在 ListTile 中创建 Flutter/Firebase 未经身份验证的用户收藏夹列表 - Can't create a Flutter/Firebase non-authenticated user favorite list in ListTile Flutter,元素类型&#39;List<ListTile> &#39;不能分配给列表类型&#39;Widget&#39; - Flutter, The element type 'List<ListTile>' can't be assigned to the list type 'Widget' Flutter - 我如何查询相同的文档 ID - 在下一页 - 作为先前单击的 ListTile - Flutter - How can i query the same document id - on the next page - as a ListTile that was previously clicked 仅更新列表中点击的 ListTile 颜色 - Updating only the tapped ListTile color in a list 如何将特定的ListTile变量传递给onTap的新页面路由? - How to pass specific ListTile variables to new page route onTap?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM