'Why Expanded widget can not add a child which is Text in Dart?
When I add a Expanded widget whose child is Text into a list,Android Studio throw a error message like this: Error: The argument type 'Expanded' can't be assigned to the parameter type 'Text'.
final List<Text> words = [];
words.add(Expanded(child: Text('hello')));
Solution 1:[1]
Expanded is a widget that can be used with(inside) Row, Column and Flex. You can't add it to a list of type Text, just remove it.
Solution 2:[2]
Try this:
final List<Text> words = [];
words.add(Text('hello'));
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 | fsbelinda |
| Solution 2 | My Car |
