Search code examples
flutterdarttextwidgetsnapshot

How can i concat text into "Text widget" with "snapshot.data" Flutter


I want to concat text inside a Text widget that contains an snapshot.data, but i couldn't do that for now. This is my code:

                               subtitle: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: <Widget>[
                                    Text(
                                      snapshot.data!.docChanges[index]
                                          .doc['entCourse'],
                                      style: TextStyle(
                                        fontSize: 13,
                                        color: Colors.grey,
                                      ),
                                    ),
                                    Text(
                                      // i think here would be the text to concat: 'Valoration is:'
                                      snapshot.data!.docChanges[index]
                                          .doc['valCourse'],
                                      style: TextStyle(
                                        fontSize: 8,
                                        color: Colors.yellowAccent,
                                      ),
                                    ),
                                  ],
                                ),

what i want is something like this

enter image description here


Solution

  • You can use string interpolation and make it without + operator something like this,

    Text("this is sample text ${snapshot.data!.docChanges[index].doc["calCourse"]}"),