Skip to content

Restrict PlatformViewCreationRequest constructor visibility#186019

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
mboetger:android-platformviewrequest-constructor-safety
May 5, 2026
Merged

Restrict PlatformViewCreationRequest constructor visibility#186019
auto-submit[bot] merged 1 commit into
flutter:masterfrom
mboetger:android-platformviewrequest-constructor-safety

Conversation

@mboetger

@mboetger mboetger commented May 4, 2026

Copy link
Copy Markdown
Contributor
  1. Restricted Constructor Visibility:
    • Changed the visibility of the primary PlatformViewCreationRequest constructor (with RequestedDisplayMode parameters) from public to private inside PlatformViewCreationRequest.java.
    • Enforced that all production callers must use the explicit, structured, mode-specific named static factory constructors (createHCPPRequest, createHybridCompositionRequest, createTLHCWithFallbackRequest).
    • Cleaned up the inline TODO(gmackall) comment inside the class declaration.
  2. Preserved Testing Contracts:
    • Kept the @VisibleForTesting constructor public/package-private so that unit tests inside
    • PlatformViewsControllerTest.java continue to compile and execute flawlessly.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

1. Restricted Constructor Visibility:
   * Changed the visibility of the primary PlatformViewCreationRequest constructor (with RequestedDisplayMode parameters) from public to private inside PlatformViewCreationRequest.java.
   * Enforced that all production callers must use the explicit, structured, mode-specific named static factory constructors (createHCPPRequest, createHybridCompositionRequest, createTLHCWithFallbackRequest).
   * Cleaned up the inline TODO(gmackall) comment inside the class declaration.
2. Preserved Testing Contracts:
   * Kept the @VisibleForTesting constructor public/package-private so that unit tests inside PlatformViewsControllerTest.java continue to compile and execute flawlessly.

TAG=agy
CONV=f1d2f12c-a509-41e0-b2da-e94d90b7a0bf
@mboetger mboetger requested a review from a team as a code owner May 4, 2026 21:28
@mboetger mboetger requested review from gmackall and removed request for a team May 4, 2026 21:28
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 4, 2026
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions Bot added platform-android Android applications specifically engine flutter/engine related. See also e: labels. team-android Owned by Android platform team labels May 4, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request changes the visibility of the PlatformViewCreationRequest constructor from public to private to enforce the use of static factory methods. Feedback was provided to update the associated Javadoc, which currently suggests a preference for static factories rather than reflecting that they are now mandatory.

* mode-specific named constructors above where possible.
*/
public PlatformViewCreationRequest(
private PlatformViewCreationRequest(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Now that this constructor is private, the Javadoc comment above (lines 127-129) is outdated. The phrase "Prefer use of the mode-specific named constructors" is no longer accurate since using the static factories is now mandatory. Please consider updating the documentation for clarity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels. l:backlog LLM created PR addressing a backlog issue. platform-android Android applications specifically team-android Owned by Android platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants