连接两个 document.data()['field'] 字段

Concatenate two document.data()['field'] fields

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

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

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