在尝试Dart的Sound Null Safety 时,我遇到了一个问题:
创建一个新的Flutter项目我发现以下(并且非常熟悉)片段代码
int _counter = 0;
void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear …Run Code Online (Sandbox Code Playgroud)