如何创建列表字符串显示



我的字符串是这样更正的:

String mathStatements;

此列表存储应用程序用户的评论数据。我想在我的应用程序的文本框中显示最近创建的评论,并且一直这样做:

Container(
child: class.mathStatements == null
new Text(class.mathStatements),

这很好用。然而,我试图用一个列表字符串来重复这个过程:

List<String> askedQuestions

但它不再工作,并给我错误消息";无法将参数类型"List"分配给参数类型"String"。我该如何解决此问题?

[推荐]如果要将其显示为列表视图,请使用ListView

ListView(
children: askedQuestions.map((e) {
return Text(e);
}).toList(),
)

或者,如果您想使用一个文本小部件来显示它,请参阅下面的代码。

Text(askedQuestions.reduce((value, element) => value + 'n' + element));

最新更新