findWidgetDetails static method
Implementation
static Future<Map<String, dynamic>> findWidgetDetails({
required String label,
required num scaleX,
required num scaleY,
num? statusBarHeight,
}) async {
final box = _resolveRenderBox(label);
if (box == null || !box.hasSize) return {'result': false};
final pos = _globalTopLeft(box);
final size = box.size;
// ✅ Check for NaN or Infinite values — return early if invalid
if (pos.dx.isNaN ||
pos.dy.isNaN ||
pos.dx.isInfinite ||
pos.dy.isInfinite ||
size.width.isNaN ||
size.height.isNaN ||
size.width.isInfinite ||
size.height.isInfinite) {
NLogger.w("Widget $label has invalid position/size: pos=$pos, size=$size");
return {'result': false, 'message': 'Widget position or size is invalid (NaN/Infinity)'};
}
// ✅ Out-of-bounds or zero-size check
if (pos.dx < 0 || pos.dy < 0 || size.width == 0 || size.height == 0) {
NLogger.w('Widget $label OOB: $pos, size: $size');
return {
'result': false,
'message': 'Widget position is partially or completely out of bounds',
};
}
return {
'result': true,
'x': pos.dx * scaleX,
'y': pos.dy * scaleY + (statusBarHeight ?? 0),
'width': size.width * scaleX,
'height': size.height * scaleY,
};
}