状态 (State) 管理参考

状态管理是一个相当复杂的话题。如果您在浏览后发现一些问题并未得到解答,或者并不适用于您的具体需求场景,自信些,您的实现就是对的。

State management is a complex topic. If you feel that some of your questions haven’t been answered, or that the approach described on these pages is not viable for your use cases, you are probably right.

通过下面的链接了解更多的信息,其中有很多信息都是由社区(第三方)提供。

Learn more at the following links, many of which have been contributed by the Flutter community:

总体概览

General overview

在选择一个具体内容前,您可以先查看以下几项。

Things to review before selecting an approach.

Provider

推荐的管理方式。

A recommended approach.

setState

适用于较小规模 widget 的暂时性状态的基础管理方法。

The low-level approach to use for widget-specific, ephemeral state.

InheritedWidget & InheritedModel

Widget tree 中不同层级间的 widget 通信的基础方法。这是诸如 provider 等众多方法的底层实现。

The low-level approach used to communicate between ancestors and children in the widget tree. This is what provider and many other approaches use under the hood.

Redux

前端开发者较为熟悉的状态容器实现。

A state container approach familiar to many web developers.

Fish-Redux

Fish Redux 是一个基于 Redux 状态管理的组合式 Flutter 应用框架,适用于构建中型和大型应用。

Fish Redux is an assembled flutter application framework based on Redux state management. It is suitable for building medium and large applications.

BLoC / Rx

基于流/观察者模式的系列。

A family of stream/observable based patterns.

MobX

一个基于观察及响应的状态管理常用库。

A popular library based on observables and reactions.

GetX

一个轻量级响应式状态管理解决方案。

A simplified reactive state management solution.