findAndUpdateWidgetPosition function
RenderBox
findAndUpdateWidgetPosition({
- required GlobalKey<
State< widgetAnchor,StatefulWidget> > - required BuildContext context,
- required VSInterfaceData data,
Implementation
RenderBox findAndUpdateWidgetPosition({
required GlobalKey widgetAnchor,
required BuildContext context,
required VSInterfaceData data,
}) {
final renderBox =
widgetAnchor.currentContext?.findRenderObject() as RenderBox;
Offset position = renderBox.localToGlobal(getWidgetCenter(renderBox));
final provider = VSNodeDataProvider.of(context);
final newOffset =
provider.applyViewPortTransfrom(position) - data.nodeData!.widgetOffset;
if (newOffset != data.widgetOffset) {
data.widgetOffset = newOffset;
provider.updateOrCreateNodes([data.nodeData!], updateHistory: false);
}
return renderBox;
}