Declarative programming thinking in state management

640?wx_fmt=jpeg

If you are already familiar with state management in responsive apps, you can skip this part, but there are also some information about state management reference for you to check.

link:

https://flutter.cn/docs/development/data-and-backend/state-mgmt/options

640?wx_fmt=gif

When you use Futter for development, you sometimes need to share the state of the application in different interfaces of the app. Here you can find many useful solutions and some questions that can be thought of.

In the next article, you will learn some basic state management knowledge.

If you are moving from an imperative framework (such as Android SDK or iOS UIKit) to Flutter applications, then you need to start thinking about app development from a new perspective.

Therefore, many assumptions under the imperative framework may not apply to Flutter. For example, this is possible in Flutter applications. Rebuild part of your interface instead of modifying it directly. If needed, Flutter can even do this quickly on every frame.

Flutter applications are declarative, which means that the user interface built by Flutter is the current state of the application.

640?wx_fmt=png

When the state of your Flutter application changes (for example, the user clicks a switch option in the settings interface), you change the state, which triggers a redraw of the user interface. It is not necessary to change the user interface itself (eg widget.setText) — you change the state, and the user interface will be rebuilt.

You can read more about declarative programming thinking in Introduction to Declarative UI.

The declarative programming style has many benefits. It is worth noting that there is only one way to encode any state changes in the user interface. Once you are given an arbitrary state, you describe what the user interface should look like, and that's it.

In the beginning, this coding style may not seem as intuitive as imperative. This is why this chapter appears here.

640?wx_fmt=png

Guess you like

Origin blog.csdn.net/weixin_43459071/article/details/102675272
Recommended