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

[Dart] Efficiently detect changes in position/size of NativeView #3

Open
alexmercerind opened this issue Mar 15, 2022 · 1 comment
Open
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@alexmercerind
Copy link
Owner

alexmercerind commented Mar 15, 2022

Right now, I just use following extension to get global coordinates of a Widget & it works great:

extension GlobalKeyExtension on GlobalKey {
Rect? get rect {
final renderObject = currentContext?.findRenderObject();
final translation = renderObject?.getTransformTo(null).getTranslation();
if (translation != null && renderObject?.paintBounds != null) {
final offset = Offset(translation.x, translation.y);
return renderObject!.paintBounds.shift(offset);
} else {
return null;
}
}
}

But, the problem is what can be an efficient way to detect when a Widget is moved on the screen or it's size is changed.

If anyone experienced in Flutter/Dart has some idea about this, please feel free to share.

Thanks.

@alexmercerind alexmercerind added help wanted Extra attention is needed good first issue Good for newcomers labels Mar 15, 2022
@abdelaziz-mahdy
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants