viewportScreenBounds property
ScreenRect
get
viewportScreenBounds
Gets the viewport extent as a ScreenRect in global screen coordinates.
This represents the screen area that displays the graph in absolute screen coordinates. This is essential for comparing with global pointer positions from gesture events (e.g., for autopan edge detection).
Returns a ScreenRect representing the global screen bounds of the viewport.
Implementation
ScreenRect get viewportScreenBounds {
final size = _screenSize.value;
// Get the global position of the canvas using the canvasKey
final renderBox =
canvasKey.currentContext?.findRenderObject() as RenderBox?;
final globalOffset = renderBox?.localToGlobal(Offset.zero) ?? Offset.zero;
return ScreenRect.fromLTWH(
globalOffset.dx,
globalOffset.dy,
size.width,
size.height,
);
}