Non-nullable by default: how to enable the experiment?

后端 未结 5 1737
礼貌的吻别
礼貌的吻别 2021-01-17 20:53

I just tried the following in DartPad:

void main() {
  int? x;
}

and get the following error:

Error compiling to JavaScript         


        
5条回答
  •  时光说笑
    2021-01-17 21:27

    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.

提交回复
热议问题