refactor: perfomance improvement on z canvas component

pull/366/head
Erick Zanardo 3 years ago
parent 24ac6a536d
commit 25bf54a2e6

@ -56,7 +56,9 @@ class _ZCanvas extends CanvasWrapper {
final List<ZIndex> _zBuffer = [];
/// Postpones the rendering of [ZIndex] component and its children.
void buffer(ZIndex component) => _zBuffer.add(component);
void buffer(ZIndex component) => _zBuffer
..add(component)
..sort((a, b) => a.zIndex.compareTo(b.zIndex));
/// Renders all [ZIndex] components and their children.
///
@ -69,8 +71,7 @@ class _ZCanvas extends CanvasWrapper {
/// before the second one.
/// {@endtemplate}
void render() => _zBuffer
..sort((a, b) => a.zIndex.compareTo(b.zIndex))
..whereType<Component>().forEach(_render)
..forEach(_render)
..clear();
void _render(Component component) => component.renderTree(canvas);

Loading…
Cancel
Save