Add vmservices for accessibilityEvaluation#182791
Add vmservices for accessibilityEvaluation#182791auto-submit[bot] merged 1 commit intoflutter:masterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces VM service extensions for accessibility evaluations, allowing tools like DevTools to trigger and retrieve accessibility rule violations (tap target size, semantic labels, and text contrast). The changes include refactoring existing evaluation classes to be more configurable and adding the necessary registration logic in WidgetsBinding. Overall, the implementation is solid, but there are several areas in the service extension callback where input validation and error handling should be improved to prevent crashes from malformed parameters.
| final Size size; | ||
|
|
||
| /// A link describing the tap target evaluations for a platform. | ||
| final String link; |
There was a problem hiding this comment.
This is a clean up, I think the link or other supplement information should be provided by the subclass or consumer class that leverage this class.
| /// * Normal text must have a contrast ratio of at least 7.0 | ||
| /// * Large or bold text must have a contrast ratio of at least 4.5 | ||
| @internal | ||
| class MinimumTextContrastEvaluationAAA extends MinimumTextContrastEvaluation { |
There was a problem hiding this comment.
This should be defined by the consumer classes like accessibilityGuidline or devtool's ui
| } | ||
|
|
||
| switch (type) { | ||
| case 'MinimumTextContrastEvaluation': |
There was a problem hiding this comment.
not sure if there is a better way to define these string since this endpoint will be called by devtools
There was a problem hiding this comment.
Are there other service extension implementations that define public constants anywhere for parameter names or types? Is there any enum associated with these names that could be used?
|
|
||
| Map<String, List<Map<String, String>>> _formatEvaluationResult(List<Violation> violations) { | ||
| return <String, List<Map<String, String>>>{ | ||
| 'result': violations.map((Violation violation) { |
There was a problem hiding this comment.
Nit: this can be written without the map and the result key (it's already part of the JSON RPC response):
return List<Map<String, String>>[
for (final violation in violations)
{
'nodeId': violation.node.id.toString(),
'message': violation.reason,
}
};Or with some object destructuring:
return List<Map<String, String>>[
for (final Violation(:node, :reason) in violations)
{
'nodeId': node.id.toString(),
'message': reason,
}
}There was a problem hiding this comment.
Will this work? ServiceExtensionCallback expects a Future<Map<String, dynamic>> as return value
There was a problem hiding this comment.
Ugh, yup, you're right. The implementation of registerServiceExtension is more restrictive than it needs to be. In theory, any JSON serializable type should be supported as a return value, as that's what ServiceExtensionResponse.result(...) accepts.
This isn't a big deal, it just means there's some unnecessary layers of collections and the RPC response will look weird.
I'd say it'd be good to fix the registerServiceExtension implementation to allow for arbitrary JSON encodable responses, but it looks like we inject the method and set the type to _extensionType in the response, assuming it's a Map. Looking through code search, we really don't need to do this as nothing I can find cares about these values in the response outside of tests and they don't add any value, so I think it'd be safe to remove them and allow for non-Map results.
I know that's extra work, so I'll leave it up to you if that's a modification you're willing to pursue.
There was a problem hiding this comment.
If we do change the return response, we may need to migrate the consumer of these endpoint. Do you know what other services we need to look into besides devtools and mcp?
I think this should probably be another pr, filed #183017
packages/flutter/test/widgets/accessibility_evaluations_service_extension_test.dart
Outdated
Show resolved
Hide resolved
packages/flutter/test/widgets/accessibility_evaluations_service_extension_test.dart
Show resolved
Hide resolved
packages/flutter/test/widgets/accessibility_evaluations_service_extension_test.dart
Outdated
Show resolved
Hide resolved
| _instance = this; | ||
| } | ||
|
|
||
| final Map<String, ServiceExtensionCallback> extensions = <String, ServiceExtensionCallback>{}; |
There was a problem hiding this comment.
Nit: Is this LHS type necessary?
There was a problem hiding this comment.
yes for public api they have to declare the type
There was a problem hiding this comment.
You should be able to use .new() to omit the RHS: https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#prefer-using-dot-shorthands-to-initialize-top-level-variables-and-fields
Up to you though.
packages/flutter/test/widgets/accessibility_evaluations_service_extension_test.dart
Outdated
Show resolved
Hide resolved
| 'targetSize': '48.0', | ||
| }); | ||
|
|
||
| expect(tapTargetResult.keys, contains('result')); |
There was a problem hiding this comment.
expect(tapTargetResult, contains('result')); should also work here.
packages/flutter/test/widgets/accessibility_evaluations_service_extension_test.dart
Outdated
Show resolved
Hide resolved
packages/flutter/test/widgets/accessibility_evaluations_service_extension_test.dart
Outdated
Show resolved
Hide resolved
packages/flutter/test/widgets/accessibility_evaluations_service_extension_test.dart
Outdated
Show resolved
Hide resolved
|
LGTM. This is a bit outside of my wheelhouse, so I'll let bkonyi approve :) |
80dbeaa to
ce17d3e
Compare
|
all comments addressed except for changing ServiceExtensionCallback return type, I filed #183017 |
|
a gentle ping |
Roll Flutter from 46fb7210422d to d3dd7744e81f (33 revisions) flutter/flutter@46fb721...d3dd774 2026-03-04 [email protected] Show warning when plugins do not support SwiftPM (flutter/flutter#182506) 2026-03-04 [email protected] Give guided message when project is not compatible with SwiftPM (flutter/flutter#182394) 2026-03-04 [email protected] Pass --web-define through to web runner when using --machine mode (flutter/flutter#183228) 2026-03-04 [email protected] Improve SwiftPM minimum platform mismatch diagnostics (flutter/flutter#182375) 2026-03-04 [email protected] Use dart::bin::SetupDartIo to setup dart:io (flutter/flutter#176714) 2026-03-04 [email protected] Roll Skia from 3197848b14ad to ada0b7628c79 (5 revisions) (flutter/flutter#183221) 2026-03-04 [email protected] Roll Skia from fe9e9f22c531 to 3197848b14ad (15 revisions) (flutter/flutter#183198) 2026-03-04 [email protected] refactor: remove material in reorderable_list_test, scroll_notification_test, scroll_physics_test, shortcuts_test, sliver_floating_header_test, snapshot_widget_test (flutter/flutter#182698) 2026-03-04 [email protected] refactor: remove material in pop_scope_test, route_notification_message_test, two_dimensional_utils, two_dimensional_viewport_test (flutter/flutter#182699) 2026-03-04 [email protected] Add dev/benchmarks/README.md (flutter/flutter#182976) 2026-03-03 [email protected] Roll RapidJSON to a branch based on the current upstream head (flutter/flutter#183048) 2026-03-03 [email protected] [Impeller] Update comments to reflect new info about 2-pass rendering (flutter/flutter#183050) 2026-03-03 [email protected] Add vmservices for accessibilityEvaluation (flutter/flutter#182791) 2026-03-03 [email protected] Roll Fuchsia Linux SDK from 0dCDM2oORHwDf_pyb... to JJw5EJ87vLGqFVl4h... (flutter/flutter#183177) 2026-03-03 [email protected] Support mixed color spaces in `Color.lerp` (flutter/flutter#182934) 2026-03-03 [email protected] Add warning when there is a widget with color between `Material` and `ListTile` (flutter/flutter#181402) 2026-03-03 [email protected] [ios]uitest for admob banner in scrollable list gesture issue (flutter/flutter#183128) 2026-03-03 [email protected] Roll Packages from faa4e22 to 9083bc9 (4 revisions) (flutter/flutter#183164) 2026-03-03 [email protected] Build App and native asset frameworks for Add to App FlutterPluginRegistrant (flutter/flutter#183136) 2026-03-03 [email protected] Roll Skia from f886711f180d to fe9e9f22c531 (4 revisions) (flutter/flutter#183155) 2026-03-03 [email protected] Roll Dart SDK from e86dbe9aa742 to c597ef90d2dc (2 revisions) (flutter/flutter#183147) 2026-03-03 [email protected] fix: bump matcher (flutter/flutter#183167) 2026-03-02 [email protected] Use isA to test for exceptions (flutter/flutter#183129) 2026-03-02 [email protected] [two_dimensional_scrollables] Fix tableview janks when first row/column pinned (flutter/flutter#180563) 2026-03-02 [email protected] Add await to callsites of BasicMessageChannel.send (flutter/flutter#182868) 2026-03-02 [email protected] Roll pub packages (flutter/flutter#183133) 2026-03-02 [email protected] Improve FFI code for windowing (flutter/flutter#183098) 2026-03-02 [email protected] [workflow] Update the changelog merge action to fetch the stable branch (flutter/flutter#183132) 2026-03-02 [email protected] Roll Skia from e180358b7a7a to f886711f180d (2 revisions) (flutter/flutter#183130) 2026-03-02 [email protected] Merge changelog from 3.41.3. (flutter/flutter#183131) 2026-03-02 [email protected] Make TextDecoration final and unify maskValue across platforms (flutter/flutter#183070) 2026-03-02 [email protected] Roll pub packages (flutter/flutter#182640) 2026-03-02 [email protected] Enable SwiftPM by default on master and beta (flutter/flutter#182923) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: ...
<!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> part of flutter#179804 still needs to wire up devtools side ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] 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. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [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 [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
part of #179804
still needs to wire up devtools side
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.