minimapContentBounds function

Rect minimapContentBounds({
  1. required GraphRect? nodesBounds,
  2. required GraphRect? visibleArea,
})

The graph rect the minimap should frame: the union of nodesBounds and the currently visible visibleArea, so the viewport indicator is always in frame even after panning away from the nodes. Either may be null.

Implementation

Rect minimapContentBounds({
  required GraphRect? nodesBounds,
  required GraphRect? visibleArea,
}) {
  final nodes = nodesBounds?.rect;
  final visible = visibleArea?.rect;
  if (nodes == null) return visible ?? Rect.zero;
  if (visible == null) return nodes;
  return nodes.expandToInclude(visible);
}