Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to prevent child widget redraw when parent widget perform setState()?

I have a ListView inside many stateFull widget of tree, and i cant able to separate from all parent widget.
Listview build from streambuilder(firebase).
From a large hierarchy of stateFull widget, some of them anytime perform setState widget, then child ListView also redraw and once again it will get data from firebase and also its flickering(blinking)

explain below example

StatefullWidget(
  child:StatefullWidget(
    child:StatefullWidget(
      child:ListView()
    ),
  ),
);

There are three parent widget of Listview(), for user friendly app setState called many time in parent widget.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

So i want to avoid flickering and redraw of listView(), even if the parent widget redraw(setState())

>Solution :

https://pub.dev/documentation/provider/latest/provider/Selector-class.html

‘selector’ of Provider is what you find.

But usually optimizing performance is enough for not blinking.
ListView.builder, const Widget, key, etc., https://api.flutter.dev/flutter/widgets/StatefulWidget-class.html#performance-considerations

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading