getCurrentViewportBox method
Implementation
RenderViewportBox? getCurrentViewportBox() {
final RenderBoxModel? currentRenderBoxModel = attachedRenderBoxModel;
if (currentRenderBoxModel == null) return null;
if (renderBoxModelInLayoutStack.isNotEmpty &&
_cachedViewportBoxLayoutPassId == renderBoxModelLayoutPassId &&
identical(_cachedViewportBoxQueryStart, currentRenderBoxModel)) {
return _cachedViewportBox;
}
flutter.RenderObject? current = currentRenderBoxModel;
while (current != null) {
if (current is RenderViewportBox) {
if (renderBoxModelInLayoutStack.isNotEmpty) {
_cachedViewportBoxLayoutPassId = renderBoxModelLayoutPassId;
_cachedViewportBoxQueryStart = currentRenderBoxModel;
_cachedViewportBox = current;
}
return current;
}
current = current.parent;
}
if (renderBoxModelInLayoutStack.isNotEmpty) {
_cachedViewportBoxLayoutPassId = renderBoxModelLayoutPassId;
_cachedViewportBoxQueryStart = currentRenderBoxModel;
_cachedViewportBox = null;
}
return null;
}