当我用CustomPaint绘制一段时间后,它延迟#103968



我知道还有其他与这个问题相关的问题,我找到了它们,我阅读了它们,但我仍然无法解决我的问题。

如果你能帮助我从GitHub查看问题,因为在那里我可以看到更详细的信息,非常感谢。

我不确定这是否会起作用,但你能试着让我知道结果吗,这是我的一个想法。我从来没有使用过bloc我也没有资格验证这个想法。希望能有所帮助。

:我觉得分太多了渲染是延迟的原因。

<<p>想法/strong>:拆分列表分成许多小数组,并使用单独的CustomPaints来渲染它们(使用Stack在彼此之上)。CustomPain.shouldRepaint还需要重写条件,以便它们仅在pointsList发生更改时才呈现。. 现在应用程序将只渲染最新的部分pointList
//...
// In previus, everytime this changes, app rerender all item.
pointList = [1, 2, 3, 4, 5, 6, 7, 8, ...];
// Now with shouldRepaint, old part will not rerender, only with newest part
pointListParts = [
[1, 2, 3],
[4, 5, 6],
[...],
]

return RepaintBoundary(
child: Stack( // Stack CustomPaint, cause shouldRepaint, old CustomPaint part will not rerendered
children: pointListParts.map((part){
return CustomPaint(
foregroundPainter: DrawingPainter(part),
);
}).toList(),
),
);
//...
class DrawingPainter extends CustomPainter {
final List<DrawnShape>? shapeList;
// ...

@override
bool shouldRepaint(DrawingPainter oldDelegate) => shapeList != oldDelegate.shapeList; // edit condition to repaint
}

最新更新