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

Issue

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.

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

Answered By – wonpyohong

Answer Checked By – Clifford M. (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *