1

I am trying to concatenate 2 fields from a firestore document. The data exists and the DropdownMenuItem populates if I use just one field. However, if I use 2 fields I get an error "Invalid arguments". How do I concatenate the 2 fields (fName and 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(),
                          );
LostTexan
  • 431
  • 5
  • 18

1 Answers1

1

You can use String interpolation for this.

child: Text('${document.data()['fName']} ${document.data()['lName']}'),
edgeboy7
  • 86
  • 1
  • 5