Dart 2.3 for,if和传播有关版本的支持警告消息

Sct*_*ajc 19 dart flutter

我收到警告消息“ 直到版本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,
                    ),
              ),
            ],
  ),
Run Code Online (Sandbox Code Playgroud)

可以正常工作。minSDKVersion等为28。为什么它认为我希望能够在任何早期版本上运行此代码?我需要将什么更改为更高版本?

fla*_*rup 35

在其中,pubspec.yaml您可以更新环境sdk来摆脱那些警告:

environment:
  sdk: ">=2.3.0 <3.0.0"
Run Code Online (Sandbox Code Playgroud)

  • 只需使用环境:sdk:“&gt; = 2.2.2 &lt;3.0.0”,因此您不必处理Flutter的非常规修补程序命名 (8认同)