From efbea05eb6b0d11a17caf143259a508c3768842e Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Thu, 19 Nov 2015 23:13:54 -0800 Subject: [PATCH] Make stocks list scrolling 2x faster on the main thread This patch improves the repaint strategy for HomogeneousViewport so that the list itself and every entry in the list has a repaint boundary. That means that we only record list items as they enter the view. --- packages/flutter/lib/src/rendering/block.dart | 1 + packages/flutter/lib/src/widgets/homogeneous_viewport.dart | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/rendering/block.dart b/packages/flutter/lib/src/rendering/block.dart index 2977e814837..9c95effd54c 100644 --- a/packages/flutter/lib/src/rendering/block.dart +++ b/packages/flutter/lib/src/rendering/block.dart @@ -255,6 +255,7 @@ class RenderBlockViewport extends RenderBlockBase { super(children: children, direction: direction, itemExtent: itemExtent, minExtent: minExtent); bool _inCallback = false; + bool get hasLayer => true; /// Called during [layout] to determine the blocks children /// diff --git a/packages/flutter/lib/src/widgets/homogeneous_viewport.dart b/packages/flutter/lib/src/widgets/homogeneous_viewport.dart index db8e0f33728..64b823aee4e 100644 --- a/packages/flutter/lib/src/widgets/homogeneous_viewport.dart +++ b/packages/flutter/lib/src/widgets/homogeneous_viewport.dart @@ -148,7 +148,9 @@ class _HomogeneousViewportElement extends RenderObjectElement newWidgets; if (_layoutItemCount > 0) - newWidgets = widget.builder(this, _layoutFirstIndex, _layoutItemCount); + newWidgets = widget.builder(this, _layoutFirstIndex, _layoutItemCount).map((Widget widget) { + return new RepaintBoundary(key: new ValueKey(widget.key), child: widget); + }).toList(); else newWidgets = []; _children = updateChildren(_children, newWidgets);