'How to create a list string display
My string is corrected like so:
String mathStatements;
This list stores data for comments made by app users. I would like to display the most recently created comment in a text box on my app and have been doing it like so:
Container(
child: class.mathStatements == null
new Text(class.mathStatements),
which works fine. However, I am trying to repeat the process with a list string:
List<String> askedQuestions
but it no longer works and gives me the error message "The argument type 'List' can't be assigned to the parameter type 'String'". How can I resolve this?
Solution 1:[1]
[Recommended] If you want to show it as a list view, use ListView.
ListView(
children: askedQuestions.map((e) {
return Text(e);
}).toList(),
)
Or, If you want to show it using one text widget see the below code.
Text(askedQuestions.reduce((value, element) => value + '\n' + element));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MaNDOOoo |
