【问题标题】:Concatenate two document.data()['field'] fields连接两个 document.data()['field'] 字段
【发布时间】:2021-08-06 19:13:52
【问题描述】:

我正在尝试连接 Firestore 文档中的 2 个字段。如果我只使用一个字段,则数据存在并且 DropdownMenuItem 会填充。但是,如果我使用 2 个字段,则会收到错误“无效参数”。如何连接 2 个字段(fName 和 lName)?

return new DropdownButton<String>(
                            hint: new Text("Select Agent"),
                            value: _currentAgent,
                            onChanged: changedDropDownAgent,
                            items: snapshot.data.docs
                                .map<DropdownMenuItem<String>>((document) {
                              return new DropdownMenuItem<String>(
                                value: document.id,
                                **child: new Text(document.data()['fName'] +
                                    document.data()['lName']),**
                              );
                            }).toList(),
                          );

【问题讨论】:

  • 你能详细说明错误吗.....

标签: flutter dropdownbutton


【解决方案1】:

您可以为此使用字符串插值。

child: Text('${document.data()['fName']} ${document.data()['lName']}'),

【讨论】:

    猜你喜欢
    • 2010-12-31
    • 1970-01-01
    • 2018-08-07
    • 1970-01-01
    • 2014-06-22
    • 1970-01-01
    • 2013-03-26
    • 2013-08-01
    • 1970-01-01
    相关资源
    最近更新 更多