b-luk e13db189f2
Broaden the applicability of Color fix_data rules from flutter/painting.dart (#181093)
See the conversation at
https://github.com/dart-lang/sdk/issues/59764#issuecomment-3599823329
for more context.

Prior to this, these `Color` fix_data rules would only be visible to
users that explicitly import `package: flutter/painting.dart`. This PR
broadens the applicability of these rules so they are visible for users
that import `dart:ui`, or import any one of the `flutter/` packages that
expose `Color`.

#### Enabling `Color` fix_data fixes for `dart:ui`:
- Adds a `fix_data.yaml` file for `'dart:ui'` fixes to
`engine/src/flutter/lib/ui/`. This contains `Color` fixes copied from
`packages/flutter/lib/fix_data/fix_painting.yaml`.
- Typically `fix_data` files go in a Dart package's `lib/` directory.
But `dart:ui` is not a standard Dart package and doesn't have a typical
`lib` directory. This directory is the closest thing to a `lib`
directory for the `dart:ui` package that I can find. It contains the
Dart code that implements the `dart:ui` package.
- The actual Dart package for `dart:ui` is generated by
`engine/src/flutter/sky/packages/sky_engine/BUILD.gn` with the package
name `sky_engine`. I updated the build rule to copy the new
`fix_data.yaml` file into the generated `sky_engine/lib/` directory.

#### Enabling `Color` fix_data fixes for `package:flutter/` libraries:
- The `Color` fixes from
`packages/flutter/lib/fix_data/fix_painting.yaml` are remove, and copied
to over to a new `packages/flutter/lib/fix_data/fix_dart_ui.yaml` file.
- This fix_data file specifies all the `flutter/` libraries which export
`Color`. With this change, importing any of these libraries will surface
the `Color` fixes, rather than only surfacing the fixes only when
`package:flutter/painting.dart` is specifically imported.

#### Other related changes
- Updates some entries in `fix_cupertino.yaml` and `fix_material.yaml`
which used the old `Color.withOpacity` method.
- Updates existing flutter package `test_fixes` tests.
- The color tests from the `painting` `test_fixes` test are moved to a
new `dart_ui` test. Note that this only runs the test with only one of
the `flutter/` libraries specified in `fix_dart_ui.yaml`
(`animation.dart`). Ideally I think we should run this test while
independently importing each one of the `flutter/` libraries specified
in `fix_dart_ui.yaml`. But AFAICT there's no easy way to do this without
creating a lot of duplicate code.
- There is no `fix_data` test for `dart:ui`. Because this isn't a
standard Dart library, I don't think there's an easy way to test its
`fix_data.yaml` in a similar way to the `flutter/` library fixes.


Somewhat fixes #180933 (makes the fixes more broadly available).
Somewhat addresses
https://github.com/dart-lang/sdk/issues/59764#issuecomment-3599823329
(establishes a way to use `fix_data.yaml` files for `dart:X` libraries).

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [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.
- [x] 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
2026-01-23 00:11:10 +00:00
..