Skip to content

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

Closed

Description

@benthillerkus

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.

Activity

  1. DanTup commented on Jan 15, 2020

    @DanTup
    Member

    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).

  2. added
    in editorRelates to code editing or language features
    in flutterRelates to running Flutter apps
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Jan 15, 2020
  3. added this to the v3.9.0 milestone on Jan 15, 2020
  4. changed the title [-]Implement refactor: Convert Color.fromARGB/RGBO() into Color()[/-] [+]Support coloured gutter icons for Color.fromARGB/RGBO()[/+] on Jan 15, 2020
  5. DanTup commented on Mar 11, 2020

    @DanTup
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin flutterRelates to running Flutter appsis enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions