最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

library

运维笔记admin13浏览0评论

library

library

mmc*_*n20 10

我遇到了同样的问题,现在当你生成 a 而不是在它现在返回的方法StatefulWidget中返回 say时,它似乎避免了返回私有类型。我最终将我所有的小部件更新为这种方法。_ExampleStatecreateStateState<Example>

所以

class Example extends StatefulWidget { const Example({Key? key}) : super(key: key); @override _ExampleState createState() => _ExampleState();}class _ExampleState extends State<Example> { @override Widget build(BuildContext context) { return Container(); }}

可以改写为

class Example extends StatefulWidget { // you can also now use a super initializer for key // if you are using dart 2.17 const Example({super.key}); // now returning State<Example> @override State<Example> createState() => _ExampleState();}class _ExampleState extends State<Example> { @override Widget build(BuildContext context) { return Container(); }}

要使用 Dart 2.17 及更高版本,请编辑 `pubspec.yaml` 并在 `environment:` 下使用:`sdk: "&gt;=2.17.0 &lt;3.0.0"` (4认同)

library

发布评论

评论列表(0)

  1. 暂无评论