Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RenderProxyBox for child position and size #34

Closed
stargazing-dino opened this issue Sep 29, 2021 · 0 comments
Closed

Use RenderProxyBox for child position and size #34

stargazing-dino opened this issue Sep 29, 2021 · 0 comments
Labels
wontfix This will not be worked on

Comments

@stargazing-dino
Copy link
Owner

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,
  );
}
@stargazing-dino stargazing-dino added the wontfix This will not be worked on label Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant