Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support coloured gutter icons for Color.fromARGB/RGBO() #2218

Closed
benthillerkus opened this issue Jan 14, 2020 · 2 comments
Closed

Support coloured gutter icons for Color.fromARGB/RGBO() #2218

benthillerkus opened this issue Jan 14, 2020 · 2 comments
Labels
in editor Relates to code editing or language features in flutter Relates to running Flutter apps is enhancement
Milestone

Comments

@benthillerkus
Copy link

This could be useful since the shorter Color(int value) constructor not only takes up less space, but also because the extension generates small color swatches on the left hand side when such a constructor is being used. The conversion is easy to do, but pretty laborious per hand as the opacity needs to be first scaled into a 0-255 range and then converted into hex.

The output would look like this:
before: Color.fromRGBO(78, 63, 93, .1)
after: const Color(0x1A4E3F5D)

So this would generally help with refactoring and cleaning up by saving time.

@DanTup
Copy link
Member

DanTup commented Jan 15, 2020

The refactors shown in VS Code come from the analysis server, so this would need to be requested there (https://github.com/dart-lang/sdk).

but also because the extension generates small color swatches on the left hand side

These are just regexes, so if the pattern is consistent I think we can support this here too:

private readonly namedColorPattern = new RegExp("Colors\\.([\\w_\\[\\]\\.]+)", "g");
private readonly colorConstructorPattern = new RegExp(" Color\\(0x([\\w_]{8})\\)", "g");

I'll keep this issue open to see if we can support that in the gutters (for the refactor, please file an SDK issue if you still think it's worthwhile after this change).

@DanTup DanTup added in editor Relates to code editing or language features in flutter Relates to running Flutter apps is enhancement labels Jan 15, 2020
@DanTup DanTup added this to the v3.9.0 milestone Jan 15, 2020
@DanTup DanTup changed the title Implement refactor: Convert Color.fromARGB/RGBO() into Color() Support coloured gutter icons for Color.fromARGB/RGBO() Jan 15, 2020
@DanTup DanTup closed this as completed in 8deb515 Mar 11, 2020
@DanTup
Copy link
Member

DanTup commented Mar 11, 2020

More formats of colours should work now:

Screenshot 2020-03-11 at 10 55 06

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in editor Relates to code editing or language features in flutter Relates to running Flutter apps is enhancement
Projects
None yet
Development

No branches or pull requests

2 participants