我有以下代码:
_places.forEach((element) {
final String name = element.name;
print(element);
places.add(Card(
child: InkWell(
splashColor: Colors.blue.withAlpha(30),
onTap: () {
print('Card tapped.');
},
child: const SizedBox(
width: 375,
height: 100,
child: Padding(
padding: EdgeInsets.all(15.00),
child: Text(
name
)
)))));
});
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是该变量name在内部使用时出错Text。
Error: Not a constant expression.
| 归档时间: |
|
| 查看次数: |
1737 次 |
| 最近记录: |