Saving final fields in Widget or in State?

Where to save the final values?

In an instance StatefulWidget(my subclass, of course) and access to it from State(subclass) through widget.thatFinalFieldor

In the most State. I have already seen both approaches. Any pros and cons for each of them?

+4
source share
1 answer

You must store finalthe member fields (which are passed through the constructor arguments) in StatefulWidgetand make them public.

StatefulWidget StatefulWidget ( ), - ( _) . initState, .

/ StatefulWidget , setState, State , .

+5

Source: https://habr.com/ru/post/1676756/


All Articles