Skip to content

状态管理章 #2

@Guo-Zhang

Description

@Guo-Zhang

提纲

状态管理章主要讲如何管理Flutter组件的状态。Flutter官方和第三方库提供了以下几种方案:

  1. StatefulWidget。优点是容易写、官方内置,缺点是不够可控、不容易复用。介绍分离页面和业务逻辑的MVC模式,主要是controller如何设计。
  2. Provider。官方推荐的第三方库,实现MVVM模式,也就是设计模式中的观察者模式。
  3. BLoC。是为了进一步更准确地控制状态,以用来写更严谨的商业软件。我们自己的最佳实践。

参考资料

Flutter官方文档:https://docs.flutter.dev/data-and-backend/state-mgmt/intro

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions