在此之前,我的代码没有错误。在将Flutter升级到最新版本之后。然后我在这里的条件是否存在错误
Column(
children: <Widget>[
if(imageFile != null) ...[
Center(
.....
),
]
],
),
这是我的错误:
This requires the 'spread-collections' experiment to be enabled.
Try enabling this experiment by adding it to the command line when compiling and running.
有人知道如何解决此错误吗?
答案 0 :(得分:1)
它是分析仪问题 要解决此问题,请在项目的根目录中创建一个名为analysis_options.yaml的文件,然后在文件中放入
analyzer:
enable-experiment:
- spread-collections
答案 1 :(得分:0)
您可以尝试使用ternary if语句
Column(
children: <Widget>[
(imageFile != null)?
Center(...) :
Text("Image Not Found"),
]
),
答案 2 :(得分:0)
请打开pubspec.yaml
并更新SDK版本,然后重新启动IDE。
environment:
sdk: ">=2.6.0 <3.0.0"