calculateRects method
Calculates and returns the rects data for the widget
Implementation
({Rect webViewRect, Rect nativeWindowRect})? calculateRects(BuildContext context) {
try {
final RenderBox? renderBox = context.findRenderObject() as RenderBox?;
if (renderBox == null || !renderBox.hasSize) {
TBLLogger.log('TBLRectUtils | calculateRects() | RenderBox is null or has no size');
return null;
}
Offset position = renderBox.localToGlobal(Offset.zero);
if (!_isWidgetInViewport(position)) {
return null;
}
Size windowSize = MediaQuery.of(context).size;
Size webViewSize = Size(windowSize.width, context.size?.height ?? 0.0);
return (
webViewRect: position & webViewSize,
nativeWindowRect: Offset(0, 0) & windowSize
);
} catch (error) {
TBLLogger.log('TBLRectUtils | calculateRects() | error: $error');
return null;
}
}