Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter 杂碎 #12

Open
noyobo opened this issue Jul 30, 2019 · 1 comment
Open

Flutter 杂碎 #12

noyobo opened this issue Jul 30, 2019 · 1 comment

Comments

@noyobo
Copy link
Owner

noyobo commented Jul 30, 2019

生命周期

flutter: initState
flutter: didChangeDependencies
flutter: build
flutter: reassemble
flutter: didUpdateWidget
flutter: build
Reloaded 0 of 508 libraries in 84ms.
flutter: reassemble
flutter: deactive
flutter: dispose
Reloaded 1 of 508 libraries in 236ms.
@noyobo
Copy link
Owner Author

noyobo commented Jul 30, 2019

  • Widget管理自己的state。
  • 父widget管理子widget状态。
  • 混合管理(父widget和子widget都管理状态)。

如何决定使用哪种管理方法?以下原则可以帮助你决定:

  • 如果状态是用户数据,如复选框的选中状态、滑块的位置,则该状态最好由父widget管理。
  • 如果状态是有关界面外观效果的,例如颜色、动画,那么状态最好由widget本身来管理。
  • 如果某一个状态是不同widget共享的则最好由它们共同的父widget管理。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant