简体   繁体   English

将 Flutter SDK 升级到最后一个版本并获取和错误如果

[英]upgrade Flutter SDK to the last version and get and Error with If

upgrade Flutter SDK to the last version and get and Error with If in the column of widget while using if to show one of widget after setstate and variable be true as shown in the image enter image description here将 Flutter SDK 升级到最新版本,并在使用 if 以在 setstate 和变量为 true 后显示其中一个小部件时在小部件列中获取和错误,如图所示在此处输入图像描述

Here they talk about other flutter update.在这里他们谈论其他 flutter 更新。 They said you should upgrade your min Dart version at pubspec.yaml Not sure if it will work but it's a similar issue than yours.他们说您应该在 pubspec.yaml 升级您的最小 Dart 版本。不确定它是否会起作用,但它与您的问题相似。

Maybe as a temp fix you could try the sintax: Condition?也许作为临时修复,您可以尝试使用 sintax:条件? True: False真假

Ups, I forgot the link:) flutter --flow-control-collections are needed, but are they? Ups,我忘记了链接:) flutter --flow-control-collections 是必需的,但它们是吗?

You can fix this by replacing the if else statement with Ternary operators .您可以通过将if else语句替换为Ternary operators来解决此问题。

Ternary Operators are shorter ways of if-else statement. Ternary Operatorsif-else语句的较短方式。 Syntax is:语法是:

testCondition? trueValue: falseValue

Check the code below: it works fine.检查下面的代码:它工作正常。

 _isLoading
          ? CircularProgressIndicator()
          : RaisedButton(
              onPressed: () {},
              child: Text('Sign up'),
            ),

I hope this helps.我希望这有帮助。

i change the SDK environment to sdk: '>=2.8.0 <3.0.0' and then flutter clean我将 SDK 环境更改为 sdk: '>=2.8.0 <3.0.0' 然后 flutter clean

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM