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: ">=2.17.0 <3.0.0"` (4认同)library