list - 如何使用 FutureBuilder 使用 List 数据构建 ListTile
问题描述
列表>_userAccounts;
结果:
_CurrentUserAccounts: [
[Current Account, 10.06, United States Dollar USD],
[Demand Deposit, 55.22, British Pound GBP],
[Current Account, 250, Euro EUR],
[Deposit Account, 0, Euro EUR]
]
格式: [AccountName, CurrentBalance, CurrencyName],
我需要使用此信息 (List>) 来构建 ListTile。这仅适用于一位用户。一些用户可能有 1 个帐户,其中一些可能有超过 10 个帐户。
显示这些数据的最佳做法是什么?我打算使用 ListTile,所以,如果用户选择 ListTile,他们可以获取特定帐户的详细信息。
那么,如何使用 FutureBuilder 使用 List 数据构建 ListTile?
解决方案
您必须为 home 或 root 小部件提供FutureBuilder的实例。正如你在下面看到的。
body: new FutureBuilder<List<Country>>(
future: fetchCountry(new http.Client()),
builder: (context, snapshot) {
if (snapshot.hasError) print(snapshot.error);
return snapshot.hasData
? new CountyList(country: snapshot.data)
: new Center(child: new CircularProgressIndicator());
},
我在这里找到了一个简单的例子。
推荐阅读
- c# - 如何使用下拉列表绑定来自不同 SQL 表的数据?
- cakephp-3.0 - 如何安装 CakePHP 控制台?
- git - Git推送成功但网站没有更新
- node.js - 纱线无法添加包(工作区内外)
- linux - 是否有关于如何调试经过测试并包含所有必要步骤的 Linux 内核的简短 A 到 Z 描述?特别是。约克托?
- python - 如何在 Tkinter 中使按钮变薄(按高度)?
- sql - 如何在我的 PIVOT 值中为每个 my 包含一个额外的非聚合列?
- python - 如果网络接口暂时关闭,是否需要超时以防止 `requests.get()` 阻塞?
- java - 如何修复 Spring Boot 应用程序的 UTF-8 编码?
- c++ - 在 C++ 中插入地图