The docs here about how to update a ListView
say:
In Flutter, if you were to update the list of widgets inside a setState(), you would quickly see that your data did not change visually. This is because when setState() is called, the Flutter rendering engine looks at the widget tree to see if anything has changed. When it gets to your ListView, it performs a == check, and determines that the two ListViews are the same. Nothing has changed, so no update is required.
For a simple way to update your ListView, create a new List inside of setState(), and copy the data from the old list to the new list.
I don't get how the Render Engine determines if there are any changes in the Widget Tree in this case.
AFAICS, we care calling setState
, which marks the State
object as dirty and asks it to rebuild. Once it rebuilds there will be a new ListView
, won't it? So how come the ==
check says it's the same object?
Also, the new List
will be internal to the State
object, does the Flutter engine compare all the objects inside the State
object? I thought it only compared the Widget
tree.
So, basically I don't understand how the Render Engine decides what it's going to update and what's going to ignore, since I can't see how creating a new List
sends any information to the Render Engine, as the docs says the Render Engine just looks for a new ListView
... And AFAIK a new List
won't create a new ListView
.