globalPaintBounds property

Rect? get globalPaintBounds

Implementation

Rect? get globalPaintBounds {
  final ctx = this.currentContext;
  if (ctx == null) return null;

  final pixelRatio = MediaQuery.of(ctx).devicePixelRatio;
  final renderBox = ctx.findRenderObject() as RenderBox?;

  if (renderBox == null) {
    print('renderBox is null');
    return Rect.zero;
  }

  final r = Rect.fromLTWH(
    (renderBox.localToGlobal(Offset.zero).dx * pixelRatio),
    (renderBox.localToGlobal(Offset.zero).dy * pixelRatio),
    (renderBox.size.width * pixelRatio),
    (renderBox.size.height * pixelRatio),
  );

  // debugPrint('''
  //   Rect from Flutter:
  //     w = ${r.width},
  //     h = ${r.height},
  //     left = ${r.left},
  //     top = ${r.top},
  //     right = ${r.right},
  //     bottom = ${r.bottom}
  // ''');

  return r;
}