Skip to content

Widgets (Draft!)

ArtemMikhaylov edited this page Jan 20, 2020 · 1 revision

It's a DRAFT!

По поводу виджетов: https://flutter.dev/docs/get-started/flutter-for/android-devs#how-do-i-update-widgets

StatelessWidgets are useful when the part of the user interface you are describing does not depend on anything other than the configuration information in the object.

For example, in Android, this is similar to placing an ImageView with your logo. The logo is not going to change during runtime, so use a StatelessWidget in Flutter.

If you want to dynamically change the UI based on data received after making an HTTP call or user interaction then you have to work with StatefulWidget and tell the Flutter framework that the widget’s State has been updated so it can update that widget.

Короче, если есть разное состояние, то используем StatefulWidget, если нет, то StatelessWidget.

Если только разные конфигурации при создании виджета - то StatelessWidget. Конфигурации мы берем при инициализации и они не меняются по ходу ЖЦ виджета. НО что если эта конфигурация должна получаться асинхронно?

If you are in doubt, then always remember this rule: if a widget changes (because of user interactions, for example) it’s stateful. However, if a widget reacts to change, the containing parent widget can still be stateless if it doesn’t itself react to change.

StatefulWidget возвращает класс State , который имеет метод build, который возвращает нужный виджет или его вариацию/состояние, в зависимости от определенного в нем состояния. Он отвечает за всю движуху, StatfullWidget в данном случае судя по всему просто обертка какая то...

Clone this wiki locally