wonders/lib/ui/common/utils/context_utils.dart
2022-08-29 20:38:28 -06:00

20 lines
490 B
Dart

import 'package:flutter/material.dart';
class ContextUtils {
static Offset? getGlobalPos(BuildContext context, [Offset offset = Offset.zero]) {
final rb = context.findRenderObject() as RenderBox?;
if (rb?.hasSize == true) {
return rb?.localToGlobal(offset);
}
return null;
}
static Size? getSize(BuildContext context) {
final rb = context.findRenderObject() as RenderBox?;
if (rb?.hasSize == true) {
return rb?.size;
}
return null;
}
}