getWidgetOffset static method
Gets the offset of a widget identified by its GlobalKey.
Returns the offset of the widget on the screen.
Example:
Offset? offset = EaseSimulator.getWidgetOffset(key);
if (offset != null) {
print("Widget Offset: $offset");
}
Implementation
static Offset? getWidgetOffset(GlobalKey key) {
try {
RenderBox renderBox = key.currentContext!.findRenderObject() as RenderBox;
return renderBox.localToGlobal(Offset.zero);
} catch (e) {
print("Failed to get widget offset: $e");
return null;
}
}