默认情况下不可为空:如何启用实验? [英] Non-nullable by default: how to enable the experiment?
本文介绍了默认情况下不可为空:如何启用实验?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚在DartPad中尝试了以下操作:
I just tried the following in DartPad:
void main() {
int? x;
}
并得到以下错误:
Error compiling to JavaScript:
main.dart:2:6:
Error: This requires the 'non-nullable' experiment to be enabled.
-
如何启用该实验?我正在使用Flutter SDK。
How do I enable that experiment? I am using the Flutter SDK.
该实验是否已经支持空安全静态分析?
Does the experiment support null-safety static analysis already?
推荐答案
您可以通过传递标志-enable-experiment = non-nullable $ c来启用实验$ c>到编译器或分析器。
You enable the experiment by passing the flag --enable-experiment=non-nullable
to the compiler or analyzer.
这还不是一个完整的功能,因此无法保证它会做什么。随时尝试,但不要在严重的问题上使用该标志。
It is not a complete feature yet, so there are no promises about what it will do. Feel free to experiment, but don't use the flag for anything serious.
这篇关于默认情况下不可为空:如何启用实验?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文