Dart 2.3 for,if和传播有关版本的支持警告消息
问题内容:
我收到警告消息“ 直到版本2.2.2才支持for,if和spread元素,但是需要此代码才能在较早版本上运行 ”,但是该代码
Column( crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
if (document['propertyid'] == '1') Text('jjj'),
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
PropertyDetails(document['propertyid'])));
},
child: Text(document['propertyname'],
style: TextStyle(
color: Colors.blue,
fontStyle: FontStyle.italic,
fontWeight: FontWeight
.w500) //Theme.of(context).textTheme.title,
),
),
],
),
如预期般运作。minSDKVersion等为28。为什么它认为我希望能够在任何早期版本上运行此代码?我需要将什么更改为更高版本?
问题答案:
在其中pubspec.yaml
您可以更新环境sdk来摆脱那些警告:
environment:
sdk: ">=2.3.0 <3.0.0"