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

fix: ⚡ Optimize GetPosition class #370

Merged
merged 1 commit into from
Mar 6, 2024

Conversation

ujas-m-simformsolutions
Copy link
Contributor

Description

Reduced call for render object. Improved conditions.

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs: etc).
  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

None.


void getRenderBox() {
var renderBox = key.currentContext?.findRenderObject() as RenderBox?;
if (renderBox != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please invert the condition and return.

Rect getRect() {
if (_box == null ||
_boxOffset == null ||
(_boxOffset?.dx.isNaN ?? true) ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create an extension for this.

if (boxOffset.dy.isNaN) return 0 - padding.top;
final topLeft = box.size.topLeft(boxOffset);
if (_box == null || _boxOffset == null || (_boxOffset?.dy.isNaN ?? true)) {
return 0 - padding.top;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you can skip subtracting from 0 and directly assign negative sign here.

@Sahil-Simform Sahil-Simform force-pushed the bugFix/improve_get_position_class branch 2 times, most recently from 36ea121 to 2f9ab68 Compare March 6, 2024 08:40
@Sahil-Simform Sahil-Simform force-pushed the bugFix/improve_get_position_class branch from 2f9ab68 to 1edfcf9 Compare March 6, 2024 08:51
@aditya-css aditya-css merged commit 66af50f into master Mar 6, 2024
2 checks passed
@aditya-css aditya-css deleted the bugFix/improve_get_position_class branch March 6, 2024 08:54
@guenth39
Copy link

When will this be released? I need the fix and therefore have to use master right now, it would be nice to be able to switch back to the pub version.

@aditya-css
Copy link
Collaborator

Hey @guenth39, We would like to inform that we have released this commit with 2.1.0 version of this package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants