Repository navigation
Scaffold view metrics overrides - #192764
Merged
auto-submit[bot] merged 16 commits intoOct 13, 2026
Merged
Conversation
The `copyWith` doc snippet referred to an undeclared `metricsOverride` variable named `override`, which resolved to `dart:core`'s top-level `const Object override`. That made analyze_snippet_code.dart report `copyWith` as undefined on `Object`, failing Tree_analyze. Declare the variable in an "Examples can assume:" block and rename it away from the `dart:core` name.
Adversarial review of this piece across four rounds. One comment was
wrong and one check had no test behind it; everything else held up.
Fixed:
* The comment introducing the `_viewMetrics` grouping said the group is
"the metrics dart:ui delivers through PlatformDispatcher.onMetricsChanged",
but the group also contains `alwaysUse24HourFormat`, which dart:ui
reports through `onPlatformConfigurationChanged` (see
`_updateUserSettingsData` in dart:ui's platform_dispatcher.dart), not
through `onMetricsChanged`. That comment exists to tell a maintainer
adding a metric which group it belongs in, so a wrong classification
rule is the one thing it has to get right. Comment only; no behaviour
change.
* The four `checkPadding` calls in `_debugAssertGeometryIsValid` had no
test behind them: deleting any of them was a silent mutation. The only
padding the tests built out of range was a `ui.ViewPadding`, which
`DebugViewPadding.fromViewPadding` rejects long before the registry
sees it, so nothing ever reached the check. `debugSetViewMetricsOverride`
now gets a padding that implements `DebugViewPadding` rather than
constructing one, which is how an out-of-range padding actually
arrives, for all four padding fields and all four edges. Verified by
deleting `checkPadding(padding, 'padding')` and watching the test
fail. Tests only; no behaviour change.
Raised in review and rejected, with the evidence, so it is not
relitigated:
* "debugSetViewMetricsOverride should return void rather than bool."
The bool is documented ("Returns true if the registered override
actually changed") and is load bearing: binding.dart consumes it at
both call sites to decide whether to post the state-changed event.
The suggested fix would break them.
* "The checkPadding calls in _debugAssertGeometryIsValid are dead code,
because DebugViewPadding's constructor already asserts its edges are
non-negative and finite." DebugViewPadding is a plain class, so it can
be implemented without ever running those asserts, and the test added
above now demonstrates the check firing.
* "platformBrightness's dartdoc describes behaviour that does not
happen yet." Every field in the class documents what overriding it
does once applied, and the class dartdoc says exactly that before
listing them, then says the framework does not apply them yet.
Rewording one field would make the class inconsistent with itself.
* "Add an inertness caveat to debugSetViewMetricsOverride's dartdoc."
The follow-up that makes overrides take effect rewrites the class
dartdoc wholesale but only inserts a paragraph into this function's,
so a caveat added here would survive that merge and contradict it.
* "Derive the service extension's accepted JSON keys from string
literals instead of DebugViewMetric.name, so that renaming an enum
value cannot change the wire format." The enum is the documented
source of truth for the accepted keys; literals would be a second
list to keep in step, which is what deriving them avoids.
* "Document debugViewMetricsOverrides as a live view rather than a
snapshot, because iterating it across an async gap could throw
ConcurrentModificationError." Nothing reads the map in this piece, so
there is no such iteration to protect.
* "Add a change notification so consumers can react." Consumers arrive
with the follow-up, and read the map rather than listening to it.
* "The service extension is registered while the feature is inert."
Expected: the extension is the interface the follow-up fills in.
victorsanni
marked this pull request as ready for review
September 17, 2026 21:16
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a new service extension, ext.flutter.viewMetricsOverride, allowing developer tooling to get, set, or clear view metric overrides for individual views in debug mode. It adds the DebugViewPadding and DebugViewMetricsOverride classes to represent and validate these overrides, along with corresponding registry management functions. Comprehensive unit tests are added to verify the serialization, validation, and service extension behavior. There are no review comments to address, and no additional feedback is provided.
chunhtai
reviewed
Sep 29, 2026
victorsanni
added a commit
to victorsanni/flutter
that referenced
this pull request
Oct 6, 2026
Mirrors the fix already on the scaffold branch (flutter#192764): the snippet's receiver is declared under "Examples can assume" and renamed from `override`, which the snippet analyzer types as Object.
- Ignore unused parameters, such as isolateId.
- Reject overrides: null; {} already removes an override.
- clearAll: 'true' ignores the other parameters.
- Post the event value as a map, not JSON text.
- Name the parameter strings; document the protocol on the enum.
chunhtai
previously approved these changes
Oct 8, 2026
chunhtai
dismissed
their stale review
October 8, 2026 18:39
accidentally approved. The only blocking one is the text scaler, all others are minor
This was referenced Oct 13, 2026
11 tasks done
This was referenced Oct 14, 2026
auto-submit Bot
pushed a commit
to flutter/packages
that referenced
this pull request
Oct 14, 2026
Roll Flutter from 4249ccbc18a3 to 426be968b5eb (44 revisions) flutter/flutter@4249ccb...426be96 2026-10-14 [email protected] Allow color delta tolerance in in-memory fuzzy image comparator (flutter/flutter#193937) 2026-10-14 [email protected] [web] Drop stale composing range after text is replaced mid-composition (flutter/flutter#194096) 2026-10-14 [email protected] Roll Skia from 2a2bbea66844 to acde3755d2e2 (1 revision) (flutter/flutter#194376) 2026-10-14 [email protected] Roll Skia from 128c983b12de to 2a2bbea66844 (1 revision) (flutter/flutter#194371) 2026-10-14 [email protected] Roll Skia from 48a294ed4955 to 128c983b12de (3 revisions) (flutter/flutter#194353) 2026-10-14 [email protected] feat(flutter_tools): extract WebDebugConfig from DebuggingOptions (flutter/flutter#194312) 2026-10-14 [email protected] Roll Skia from ea6781c5b6d1 to 48a294ed4955 (2 revisions) (flutter/flutter#194349) 2026-10-14 [email protected] Include <vector> in Android proc_table.h. (flutter/flutter#194325) 2026-10-14 [email protected] Roll Dart SDK from 5933cb486b4a to 6b50116630d0 (28 revisions) (flutter/flutter#194341) 2026-10-14 [email protected] Move GLES3 instancing API entry points to FOR_EACH_IMPELLER_GLES3_PROC (flutter/flutter#194319) 2026-10-14 [email protected] feat(flutter_tools): extract AndroidGradleConfig and move toGradleConfig to AndroidBuildInfo (flutter/flutter#194016) 2026-10-14 [email protected] Roll Skia from ae297bec6012 to ea6781c5b6d1 (8 revisions) (flutter/flutter#194331) 2026-10-14 [email protected] [flutter_tools] Migrate gradle_errors and deferred_components_prebuild_validator away from globals (flutter/flutter#193649) 2026-10-14 [email protected] [Impeller] Cache GLES sampler configuration in RenderPassStateCache (flutter/flutter#193922) 2026-10-14 [email protected] Roll pub packages (flutter/flutter#194332) 2026-10-13 [email protected] [tool] Migrate RunCommand to modular dependency injection (flutter/flutter#190791) 2026-10-13 [email protected] Include `engine/src/flutter/.ci.yaml` in quarterly `goldctl` checklist (flutter/flutter#194316) 2026-10-13 [email protected] [flutter_tools] Remove the last AMD module system support (flutter/flutter#193607) 2026-10-13 [email protected] Roll Skia from 8b3394a60654 to ae297bec6012 (5 revisions) (flutter/flutter#194310) 2026-10-13 [email protected] [web] Remove the a11y placeholder only after the gesture ends (flutter/flutter#194109) 2026-10-13 [email protected] Upgrade goldctl to the latest version (flutter/flutter#193932) 2026-10-13 [email protected] [flutter_tools] Lazily initialize AndroidStudio validation and optimize candidate selection (flutter/flutter#191968) 2026-10-13 [email protected] [flutter_tools] Clean up outdated widget preview TODOs and refactor static state (flutter/flutter#189437) 2026-10-13 [email protected] Roll Skia from e5b5db6d0d6f to 8b3394a60654 (2 revisions) (flutter/flutter#194306) 2026-10-13 [email protected] Redistribute TESTOWNERS for Android team (flutter/flutter#193861) 2026-10-13 [email protected] feat(flutter_tools): introduce Test and Drive specification objects (flutter/flutter#194017) 2026-10-13 [email protected] [Impeller] Keep the aspect ratio when shrinking images to the max texture size (flutter/flutter#194010) 2026-10-13 [email protected] [flutter tool] preserve inherited `DASH__SUPPRESS_ANALYTICS=true` for sub-tools (flutter/flutter#194261) 2026-10-13 [email protected] Roll Packages from d8d9e97 to a1ed23c (9 revisions) (flutter/flutter#194302) 2026-10-13 [email protected] Use PE/COFF AOT snapshots for Windows x64 (flutter/flutter#187594) 2026-10-13 [email protected] Fix Expansible crash when PageStorage holds a non-bool value (flutter/flutter#192195) 2026-10-13 [email protected] Roll Skia from ffeccb3ca58a to e5b5db6d0d6f (1 revision) (flutter/flutter#194297) 2026-10-13 [email protected] Explain why initState() is too early to depend on an inherited widget (flutter/flutter#192727) 2026-10-13 [email protected] Refactor TestPlatformDispatcher (flutter/flutter#192747) 2026-10-13 [email protected] Roll Skia from 3de0984208ec to ffeccb3ca58a (2 revisions) (flutter/flutter#194291) 2026-10-13 [email protected] Roll Skia from 0580c2b780f6 to 3de0984208ec (2 revisions) (flutter/flutter#194281) 2026-10-13 [email protected] Roll Skia from f641d55e07a8 to 0580c2b780f6 (3 revisions) (flutter/flutter#194275) 2026-10-13 [email protected] Roll Skia from 0e5d8d1be81b to f641d55e07a8 (1 revision) (flutter/flutter#194266) 2026-10-13 [email protected] Scaffold view metrics overrides (flutter/flutter#192764) 2026-10-13 [email protected] [web] Add SemanticsRole.listBox and SemanticsRole.option (flutter/flutter#192971) 2026-10-13 [email protected] Pin mac_unopt to macOS 15 (flutter/flutter#194254) 2026-10-13 [email protected] Roll pub packages (flutter/flutter#194257) 2026-10-12 [email protected] Roll Skia from 17f6986c226c to 0e5d8d1be81b (4 revisions) (flutter/flutter#194249) 2026-10-12 [email protected] Make DisplayLists' use of DlPaint, SkPaint, and impeller::Paint agree on the default isAntiAlias (flutter/flutter#193939) If this roll has caused a breakage, revert this CL and set the roller ...
suryaKommana2662
pushed a commit
to suryaKommana2662/flutter
that referenced
this pull request
Oct 29, 2026
Scaffolding for `DebugViewMetricsOverride`, `DebugViewPadding`, `debugViewMetricsOverrides`, and the `ext.flutter.viewMetricsOverride` service extension. Part of flutter/devtools#9893 Implements Option 2 in https://flutter.dev/go/view-metrics-overrides.
bkonyi
pushed a commit
to bkonyi/flutter
that referenced
this pull request
Oct 30, 2026
Part of flutter/devtools#9893 (the DevTools accessibility page). Design: [flutter.dev/go/view-metrics-overrides](https://flutter.dev/go/view-metrics-overrides). flutter#192764 added the `debugViewMetricsOverrides` registry and the `ext.flutter.viewMetricsOverride` service extension. This PR makes those overrides take effect, which the DevTools override controls depend on. Next up: `flutter_test` support for test views with their own ids, and moving `ext.flutter.brightnessOverride` onto the registry. ## What this does In debug mode, `BindingBase.platformDispatcher` wraps `PlatformDispatcher.instance`. The wrapper and its views report overridden metrics, so everything that reads them through the binding (`MediaQuery`, `RenderView`, gestures, semantics, image resolution, accessibility evaluations) sees the overrides without any override-specific code. Changing an override fires the same `dart:ui` callbacks a real platform change would. `RenderView`, `View`, `RawView` and `MediaQueryData.fromView` map a raw engine view to the binding's wrapped one, so overrides apply to it too. Widget tests see overrides through `TestWidgetsFlutterBinding`, and explicit test values still take precedence. Profile and release builds are unchanged. New API: `debugApplyViewMetricsOverrides` wraps a dispatcher, for bindings that supply their own, and `debugViewWithMetricsOverrides` maps a raw engine view to its wrapper. ## Behavior changes and caveats - Debug only: `View.of(context)` and the binding's views are no longer `identical` to the ones `PlatformDispatcher.instance` reports. A view's `platformDispatcher` is a wrapper for that view, not `PlatformDispatcher.instance` or an app binding's dispatcher. Compare views by `viewId`. - Debug only: a `FlutterView` test double passed to `View`, `RawView`, `RenderView` or `MediaQueryData.fromView` must implement `platformDispatcher` and `viewId`. - `TestPlatformDispatcher.scaleFontSize` asks the wrapped dispatcher unless `textScaleFactorTestValue` is set, so non-linear text scaling applies in tests. A fake dispatcher without `scaleFontSize` still gets linear scaling. - An overridden `physicalSize` lays out at that size but still renders into the real surface, anchored top-left. - An ancestor `MediaQuery` still wins over platform-wide overrides, as it does over real platform settings. `debugBrightnessOverride` still wins over an overridden brightness. - `ui.window`, direct `PlatformDispatcher.instance` reads and engine-drawn content (platform views, system UI, keyboard) don't see overrides. - Text scalers compare by `textScaleFactor`, so a new `textScaling` table with the same first-point ratio only reaches already laid-out text when that text lays out again. ## Tests - `foundation/debug_view_metrics_override_test.dart`: the wrappers, per metric and per view, plus view identity, normalization, change notifications and validation. - `widgets/debug_view_metrics_override_test.dart`: end to end through `MediaQuery`, views, layout, pointer events, semantics, images and accessibility evaluations, and precedence of explicit test values. - `service_extensions_test.dart` covers an override set through the extension. `platform_dispatcher_test.dart` covers `scaleFontSize` delegation and its fallback for fakes. ## 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 in-code documentation (doc comments with `///`). - [x] If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed). - [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. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- 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/CONTRIBUTING.ai.md [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/ [flutter/tests]: https://github.com/flutter/tests [flutter/website]: https://github.com/flutter/website [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
7 of 23 tasks
gmackall
pushed a commit
to gmackall/flutter
that referenced
this pull request
Nov 3, 2026
Part of flutter/devtools#9893 (the DevTools accessibility page). Design: [flutter.dev/go/view-metrics-overrides](https://flutter.dev/go/view-metrics-overrides). flutter#192764 added the `debugViewMetricsOverrides` registry and the `ext.flutter.viewMetricsOverride` service extension. This PR makes those overrides take effect, which the DevTools override controls depend on. Next up: `flutter_test` support for test views with their own ids, and moving `ext.flutter.brightnessOverride` onto the registry. ## What this does In debug mode, `BindingBase.platformDispatcher` wraps `PlatformDispatcher.instance`. The wrapper and its views report overridden metrics, so everything that reads them through the binding (`MediaQuery`, `RenderView`, gestures, semantics, image resolution, accessibility evaluations) sees the overrides without any override-specific code. Changing an override fires the same `dart:ui` callbacks a real platform change would. `RenderView`, `View`, `RawView` and `MediaQueryData.fromView` map a raw engine view to the binding's wrapped one, so overrides apply to it too. Widget tests see overrides through `TestWidgetsFlutterBinding`, and explicit test values still take precedence. Profile and release builds are unchanged. New API: `debugApplyViewMetricsOverrides` wraps a dispatcher, for bindings that supply their own, and `debugViewWithMetricsOverrides` maps a raw engine view to its wrapper. ## Behavior changes and caveats - Debug only: `View.of(context)` and the binding's views are no longer `identical` to the ones `PlatformDispatcher.instance` reports. A view's `platformDispatcher` is a wrapper for that view, not `PlatformDispatcher.instance` or an app binding's dispatcher. Compare views by `viewId`. - Debug only: a `FlutterView` test double passed to `View`, `RawView`, `RenderView` or `MediaQueryData.fromView` must implement `platformDispatcher` and `viewId`. - `TestPlatformDispatcher.scaleFontSize` asks the wrapped dispatcher unless `textScaleFactorTestValue` is set, so non-linear text scaling applies in tests. A fake dispatcher without `scaleFontSize` still gets linear scaling. - An overridden `physicalSize` lays out at that size but still renders into the real surface, anchored top-left. - An ancestor `MediaQuery` still wins over platform-wide overrides, as it does over real platform settings. `debugBrightnessOverride` still wins over an overridden brightness. - `ui.window`, direct `PlatformDispatcher.instance` reads and engine-drawn content (platform views, system UI, keyboard) don't see overrides. - Text scalers compare by `textScaleFactor`, so a new `textScaling` table with the same first-point ratio only reaches already laid-out text when that text lays out again. ## Tests - `foundation/debug_view_metrics_override_test.dart`: the wrappers, per metric and per view, plus view identity, normalization, change notifications and validation. - `widgets/debug_view_metrics_override_test.dart`: end to end through `MediaQuery`, views, layout, pointer events, semantics, images and accessibility evaluations, and precedence of explicit test values. - `service_extensions_test.dart` covers an override set through the extension. `platform_dispatcher_test.dart` covers `scaleFontSize` delegation and its fallback for fakes. ## 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 in-code documentation (doc comments with `///`). - [x] If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed). - [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. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- 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/CONTRIBUTING.ai.md [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/ [flutter/tests]: https://github.com/flutter/tests [flutter/website]: https://github.com/flutter/website [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scaffolding for
DebugViewMetricsOverride,DebugViewPadding,debugViewMetricsOverrides, and theext.flutter.viewMetricsOverrideservice extension.Part of flutter/devtools#9893
Implements Option 2 in https://flutter.dev/go/view-metrics-overrides.