[英] library_private_types_in_public_api and StatefulWidget
在我的pubspec中将linter升级到新版本(flutter_lints: 2.0.1
)之后
顺便说一句:我知道我可以禁用这个规则.
在我的pubspec中将linter升级到新版本(flutter_lints: 2.0.1
)之后
顺便说一句:我知道我可以禁用这个规则.
我遇到了同样的问题,现在当你生成一个StatefulWidget
而不是在createState
方法中返回_ExampleState
时,它现在返回State<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 al所以 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();
}
}
在按下另一个小部件 timeshift 除 TextField 焦点
如何在Flutter 中解析 Web 套接字响应(JSON)
从 Flutter iso8601 到 Go api RFC3339 的错误解码日期
在 Flutter 中,AlertDialog 按钮不起作用
您如何发送获取请求以获取 Dropbox 访问令牌,我发现让获取请求正常工作真的很棘手
ListView Builder 与 SingleChildScrollView + Row 组合
在 Flutter 中,如何通过 checklisttile 使单个 tab 键击到 tab?
安装 Flutter 和 Android Studio 后出现错误“缺少 cmdline-tools 组件”...我添加了 Android SDK.我该如何解决它们?