mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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
106 lines
2.9 KiB
YAML
106 lines
2.9 KiB
YAML
# Copyright 2014 The Flutter Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
# For details regarding the *Flutter Fix* feature, see
|
|
# https://flutter.dev/to/flutter-fix
|
|
|
|
# Please add new fixes to the top of the file, separated by one blank line
|
|
# from other fixes. In a comment, include a link to the PR where the change
|
|
# requiring the fix was made.
|
|
|
|
# Every fix must be tested. See the flutter/packages/flutter/test_fixes/README.md
|
|
# file for instructions on testing these data driven fixes.
|
|
|
|
# For documentation about this file format, see
|
|
# https://dart.dev/go/data-driven-fixes.
|
|
|
|
# * Fixes in this file are for classes exported from the 'dart:ui' library. *
|
|
# This file mirrors the Flutter Engine's 'dart:ui' fixes found at
|
|
# engine/src/flutter/lib/ui/fix_dart_ui.yaml. The Engine's file is the source
|
|
# of truth. Its fixes are duplicated here to ensure they apply to 'dart:ui'
|
|
# classes re-exported by 'package:flutter' libraries.
|
|
|
|
# Uncomment version & transforms, and follow with fixes.
|
|
version: 1
|
|
transforms:
|
|
- title: "Rename from 'opacity' to 'a'"
|
|
date: 2024-09-10
|
|
element:
|
|
uris: [
|
|
'animation.dart',
|
|
'cupertino.dart',
|
|
'material.dart',
|
|
'painting.dart',
|
|
'rendering.dart',
|
|
'services.dart',
|
|
'widgets.dart',
|
|
]
|
|
method: 'opacity'
|
|
inClass: 'Color'
|
|
changes:
|
|
- kind: 'rename'
|
|
newName: 'a'
|
|
|
|
- title: "Replace 'value' with 'toARGB32()'"
|
|
date: 2025-02-03
|
|
element:
|
|
uris: [
|
|
'animation.dart',
|
|
'cupertino.dart',
|
|
'material.dart',
|
|
'painting.dart',
|
|
'rendering.dart',
|
|
'services.dart',
|
|
'widgets.dart',
|
|
]
|
|
method: 'value'
|
|
inClass: 'Color'
|
|
changes:
|
|
- kind: 'replacedBy'
|
|
newElement:
|
|
uris: [
|
|
'animation.dart',
|
|
'cupertino.dart',
|
|
'material.dart',
|
|
'painting.dart',
|
|
'rendering.dart',
|
|
'services.dart',
|
|
'widgets.dart',
|
|
]
|
|
method: 'toARGB32'
|
|
inClass: 'Color'
|
|
|
|
- title: "Rename 'withOpacity'"
|
|
date: 2024-09-10
|
|
element:
|
|
uris: [
|
|
'animation.dart',
|
|
'cupertino.dart',
|
|
'material.dart',
|
|
'painting.dart',
|
|
'rendering.dart',
|
|
'services.dart',
|
|
'widgets.dart',
|
|
]
|
|
method: 'withOpacity'
|
|
inClass: 'Color'
|
|
changes:
|
|
- kind: 'rename'
|
|
newName: 'withValues'
|
|
- kind: 'removeParameter'
|
|
index: 0
|
|
- kind: 'addParameter'
|
|
index: 0
|
|
name: 'alpha'
|
|
style: optional_named
|
|
argumentValue:
|
|
expression: '{% opacity %}'
|
|
requiredIf: "opacity != ''"
|
|
variables:
|
|
opacity:
|
|
kind: 'fragment'
|
|
value: 'arguments[0]'
|
|
|
|
# Before adding a new fix: read instructions at the top of this file.
|