Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
339 views
in Technique[技术] by (71.8m points)

Flutter, many StatefulWidget would be a problem?

I want to create and manage many stateful widgets, (for clean code)

but I am afraid that many stateful widgets will create memory issues.

In general, how many stateful widgets can be nested without issue? (assume, the widget size to a minimum (like one Container widget))

how can I check the memory cost of one stateful widget? In android studio?

For example, suppose you have 100 stateful widgets nested. This will be much slower than writing all the code in one stateful widget class, right? Or is there not much difference in speed or memory? So, you can freely use like 100 nested Stateful Widgets?

question from:https://stackoverflow.com/questions/65939345/flutter-many-statefulwidget-would-be-a-problem

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Many Stateful widgets won’t cause a problem for memory, but I’d highly recommend using a state manager like ‘flutter_bloc’ so you can create more stateless widgets while bloc can still provide state management for your widgets.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...