getOrBuild method
Implementation
Path getOrBuild(StrokeNode node) {
final points = node.points;
if (points.length < 2) {
throw StateError(
'SceneStrokePathCache.getOrBuild requires points.length >= 2. '
'Dots must be handled separately.',
);
}
final firstPoint = points.first;
final lastPoint = points.last;
final cached = _entries.remove(node.id);
if (cached != null &&
cached.pointsLength == points.length &&
cached.firstPoint == firstPoint &&
cached.lastPoint == lastPoint) {
_entries[node.id] = cached;
_debugHitCount += 1;
return cached.path;
}
final path = _buildStrokePath(points);
_entries[node.id] = _StrokePathEntry(
path: path,
pointsLength: points.length,
firstPoint: firstPoint,
lastPoint: lastPoint,
);
_debugBuildCount += 1;
_evictIfNeeded();
return path;
}