Although I do think what I'm currently doing is a little bit hacky, considering I have 10+ fields on the widget state, I'd need to create those same fields on the CustomRenderObject and update them all accordingly. This is super verbose.
My current workaround is just to get the RenderBox of child's self at runtime when it's requested to show a tooltip.
TargetInformation _getTargetInformation(BuildContext context) {
final box = context.findRenderObject() as RenderBox?;
if (box == null) {
throw StateError(
'Cannot find the box for the given object with context $context',
);
}
final targetSize = box.getDryLayout(const BoxConstraints.tightForFinite());
final target = box.localToGlobal(box.size.center(Offset.zero));
final offsetToTarget = Offset(
-target.dx + box.size.width / 2,
-target.dy + box.size.height / 2,
);
return TargetInformation(
targetSize,
target,
offsetToTarget,
);
}
Although I do think what I'm currently doing is a little bit hacky, considering I have 10+ fields on the widget state, I'd need to create those same fields on the CustomRenderObject and update them all accordingly. This is super verbose.
My current workaround is just to get the RenderBox of child's self at runtime when it's requested to show a tooltip.