简体   繁体   English

如何使用“snapshot.data”将文本连接到“文本小部件”Flutter

[英]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.我想在包含 snapshot.data 的 Text 小部件中连接文本,但我现在不能这样做。 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我想要的是这样的

在此处输入图像描述

You can use string interpolation and make it without + operator something like this,您可以使用字符串插值并使其不使用 + 运算符,如下所示,

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM