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

refactor: Resize logic in GameRenderBox #1308

Merged
merged 2 commits into from
Jan 12, 2022
Merged

Conversation

st-pasha
Copy link
Contributor

Description

The documentation of RenderBox says the following:

/// When implementing a [RenderBox] subclass, one must make a choice. Does it
/// size itself exclusively based on the constraints, or does it use any other
/// information in sizing itself? An example of sizing purely based on the
/// constraints would be growing to fit the parent.
///
/// Sizing purely based on the constraints allows the system to make some
/// significant optimizations. Classes that use this approach should override
/// [sizedByParent] to return true, and then override [computeDryLayout] to
/// compute the [Size] using nothing but the constraints, e.g.:

This PR changes GameRenderBox to adhere to this advice and set sizedByParent to true.

Checklist

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

Breaking Change

  • No, this is not a breaking change.

Related Issues

Maybe helps with #1293 ?

@@ -58,11 +57,6 @@ class GameRenderBox extends RenderBox with WidgetsBindingObserver {
markNeedsPaint();
}

@override
void performLayout() {
Copy link
Member

Choose a reason for hiding this comment

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

don't you still need to update the size variable when flutter changes our size?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@luanpotter luanpotter left a comment

Choose a reason for hiding this comment

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

Nice!

@spydon
Copy link
Member

spydon commented Jan 12, 2022

Seems like @renancaraujo changed it the other way around here:
#845

Copy link
Member

@renancaraujo renancaraujo left a comment

Choose a reason for hiding this comment

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

Makes sense now.

@spydon spydon merged commit 17c45c2 into flame-engine:main Jan 12, 2022
@st-pasha st-pasha deleted the ps/resize branch January 12, 2022 22:23
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.

4 participants