初学Flutter Each child must be laid out exactly once

According to knock Flutter Chinese network codes

class RandomWords extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return new RandomWordState();
  }
}

class RandomWordState extends State<RandomWords>{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    final wordPair=new WordPair.random();
    return new Text(wordPair.asCamelCase);
  }
}

Save error:

Each child must be laid out exactly once

The code initially thought he was wrong, then up to the beginning of the revocation, save, or error

The final restart, that is, click on the triangle run successfully

Return to the code above, re-run the code, run successfully

So it should be required to restart

发布了13 篇原创文章 · 获赞 5 · 访问量 2万+

Guess you like

Origin blog.csdn.net/u013241923/article/details/104696176