morphAnchorRect function

Rect morphAnchorRect(
  1. BuildContext context
)

The rect of context's render box in the coordinate space of the enclosing Overlay - the space every flight, and therefore every MorphTargetSpec.rectFor, works in. Use it to capture popover anchors at tap time: a raw localToGlobal returns SCREEN coordinates, which silently drift from overlay coordinates the moment the morph lives inside a nested navigator.

Implementation

Rect morphAnchorRect(BuildContext context) {
  final Rect? rect = maybeMorphAnchorRect(context);
  assert(
    rect != null,
    'morphAnchorRect: the context has no laid-out RenderBox (called '
    'before the first layout, or from a removed widget). Capture the '
    'anchor at tap time, or use maybeMorphAnchorRect to degrade.',
  );
  return rect!;
}