rect property Null safety

Rect rect

Returns the global rectangle of the attached widget's RenderObject, in logical units.

Rect is the rectangle of the transformed widget in global coordinates.


Rect get rect {
    context != null,
    "Tried to get the bounds of a focus node that didn't have its context set yet.\n"
    'The context needs to be set before trying to evaluate traversal policies. '
    'Setting the context is typically done with the attach method.',
  final RenderObject object = context!.findRenderObject()!;
  final Offset topLeft = MatrixUtils.transformPoint(object.getTransformTo(null), object.semanticBounds.topLeft);
  final Offset bottomRight = MatrixUtils.transformPoint(object.getTransformTo(null), object.semanticBounds.bottomRight);
  return Rect.fromLTRB(topLeft.dx, topLeft.dy, bottomRight.dx, bottomRight.dy);