You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🐛 Resolves the referenced element before parsing colors (#6768)
Fixes#5436.
| Before | After |
|------|------|
|

|

|
## Implementation details
- `Colors` and `CupertinoColors` are hard-coded to determine *colored
element*. The condition has been removed, which means all elements will
be predicated.
- Referenced will be resolved before the element gets parsed by text
directly.
- All the additional checks will be called only if the element type is
`VAR_INIT` (for declarations) or `FUNCTION_BODY` (for getters) to avoid
too much performance regression.
Test case:
```dart
import 'package:flutter/material.dart' hide Colors;
const Color _c1 = Color(0xff000000);
final _c2 = _c1;
Color get _c3 => _c2;
void test() {
const Color c1 = _c1;
const Color c2 = Color(0xffffffff);
const Color c3 = Color.fromARGB(255, 123, 231, 31);
const Color c4 = Color(0xff923998);
const Color c5 = c2;
const Color c6 = TC.c1;
const Color c7 = TC.c2;
const Color c8 = TC.c3;
const Color c9 = Colors.black;
}
class TC {
static const Color c1 = Color(0xff449978);
static const Color c2 = Color(0xffdb2f7f);
static const Color c3 = Color.fromARGB(150, 66, 231, 31);
}
class Colors {
static const Color white = Color(0xffaa9933);
static const Color tests = Colors.white;
static const Color black = Colors.tests;
static const Color tcC1 = TC.c1;
final Color tcC2 = TC.c2;
Color get tcC3 => TC.c3;
}
```
## 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 the [Flutter Style Guide] _recently_, and have followed its
advice.
- [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 `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] All existing and new tests are passing.
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
0 commit comments