mirror of
https://github.com/flutter/flutter
synced 2024-10-13 19:52:53 +00:00
Slightly improve comments in SliverMultiBoxAdaptorElement (#10939)
I got a bit confused by these comments when trying to debug this code, let's try clearing them up a little.
This commit is contained in:
parent
df1a01b3b3
commit
59524c697b
|
@ -577,13 +577,20 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
|
|||
performRebuild();
|
||||
}
|
||||
|
||||
final SplayTreeMap<int, Element> _childElements = new SplayTreeMap<int, Element>();
|
||||
// We inflate widgets at two different times:
|
||||
// 1. When we ourselves are told to rebuild (see performRebuild).
|
||||
// 2. When our render object needs a new child (see createChild).
|
||||
// In both cases, we cache the results of calling into our delegate to get the widget,
|
||||
// so that if we do case 2 later, we don't call the builder again.
|
||||
// Any time we do case 1, though, we reset the cache.
|
||||
|
||||
final Map<int, Widget> _childWidgets = new HashMap<int, Widget>();
|
||||
final SplayTreeMap<int, Element> _childElements = new SplayTreeMap<int, Element>();
|
||||
RenderBox _currentBeforeChild;
|
||||
|
||||
@override
|
||||
void performRebuild() {
|
||||
_childWidgets.clear();
|
||||
_childWidgets.clear(); // Reset the cache, as described above.
|
||||
super.performRebuild();
|
||||
_currentBeforeChild = null;
|
||||
assert(_currentlyUpdatingChildIndex == null);
|
||||
|
@ -596,9 +603,6 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
|
|||
} else if (_didUnderflow) {
|
||||
lastIndex += 1;
|
||||
}
|
||||
// We won't call the delegate's build function multiple times, because we
|
||||
// cache the delegate's results until the next time we need to rebuild the
|
||||
// whole widget.
|
||||
for (int index = firstIndex; index <= lastIndex; ++index) {
|
||||
_currentlyUpdatingChildIndex = index;
|
||||
final Element newChild = updateChild(_childElements[index], _build(index), index);
|
||||
|
|
Loading…
Reference in a new issue