1

我正在尝试连接 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(),
                          );
4

1 回答 1

1

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

child: Text('${document.data()['fName']} ${document.data()['lName']}'),
于 2021-05-17T17:06:47.163 回答