SIGN IN SIGN UP

Don't size or offset the Android platform view before it is laid out (#190895)

`RenderAndroidView` reads its own size from two places that can run
before the first layout: the post
frame callback in `_setOffset`, and `_sizePlatformView` when the
controller is swapped. A platform view
mounted while a route transition is in flight is attached before its
route has laid out, so both throw
`RenderBox was not laid out` from a future that nothing can catch.

Both now check `hasSize` first, the same guard
`_handleGlobalPointerEvent` got for the equivalent iOS
crash in #83481. Nothing is lost by waiting: the offset callback
reschedules itself every frame, and
`performResize` sizes the platform view as soon as layout gives it a
size.

One regression test per path in
`packages/flutter/test/rendering/platform_view_test.dart`, both built
the way the existing `RenderUiKitView` test for #83481 is, and both fail
without the change.

Fixes https://github.com/flutter/flutter/issues/190833

## Pre-launch Checklist

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
W
William Yang committed
247215b2bef864d5059f611aa5c942b0d74fb0fd
Parent: bf29b60
Committed by GitHub <noreply@github.com> on 8/20/2026, 10:16:04 PM