首页 > 解决方案 > 在状态类中使用私有字段的感觉

问题描述

在状态类中使用私有字段是什么感觉?你打算做一个_SimpleExampleState其他人的例子吗?在哪里?!已经是私有的_SimpleExampleState,那为什么那些人将私有用于状态类字段?

举一个可能有帮助的例子。

...
class _SimpleExampleState extends State<SimpleExample> {
  final GlobalKey<ScaffoldMessengerState> _scaffoldMessengerKey =
      GlobalKey<ScaffoldMessengerState>();

  ReactionDisposer? _disposer;

  @override
  void initState() { ...

标签: flutter

解决方案


推荐阅读