flutter / flutter-intellij

Flutter Plugin for IntelliJ
https://flutter.dev/using-ide
BSD 3-Clause "New" or "Revised" License
1.98k stars 318 forks source link

Color picker does not work #5780

Open ghost opened 3 years ago

ghost commented 3 years ago

Steps to Reproduce

The color picker in the gutter does not work:

https://1drv.ms/u/s!AsFZusAnvKobgSdqPimyQvn4jzbt?e=XZwpKy

stevemessick commented 3 years ago

I can't open that link. Please provide details of the problem here. Unless it is due to this issue noted in the release notes:

Caveat: the color picker appears for all color icons but its selection is ignored if the color is a named Material or Cupertino color.

If that's the problem, you can close this issue because we do not plan to fix it.

ghost commented 3 years ago

Caveat: the color picker appears for all color icons but its selection is ignored if the color is a named Material or Cupertino color.

Yes this is it. Apparently this is the source of this statement:

https://groups.google.com/g/flutter-announce/c/V335xbsPWUs/m/14LSp05kAQAJ

Can you describe why this issue is "wont fix"? It is a usability issue and it appears to be within the limits of intellij sdk. (is it?)

jacob314 commented 3 years ago

I tried out this functionality and it is great when it works but there a few bugs.

Problems with the current behavior:

  1. Editing a line after it already has a color values makes the color icon stop being editable for some reason. For example, adding a const where one was missing reproduces this.
  2. Color values like Colors.red display a color picker but the value is not saved which is confusing and makes it seem like our code editing functionality is broken. I think users would prefer to save the color value even if it overrides a nice material color constant with a hex value. We can tackle fixing up color values to reuse existing color constants with a separate lint and quick fix. I would suggest we emit color values as Color(0xFFAF9299). As a bonus we could emit the color as a Colors.foo constant if the exact value matched one of the material colors but that isn't crucial for an MVP. We could also consider adding a lint and quick fix that detects any case where a user is specifying colors as raw values when there are appropriate constants. https://github.com/dart-lang/sdk/issues/58525
stevemessick commented 3 years ago

When working with named color constants, code completion works great. Making the color picker work equivalently is a lot of work, which was why I said we don't plan to fix it. We'll leave it open, though.

The reason the color picker is displayed for named colors is to provide the preview, and I couldn't find a way to disable the "picker" part of the preview. If IntelliJ adds that, then we can stop displaying the input selector. I think rewriting a named value to a hex value would be a surprising and unwelcome UX, though.

jacob314 commented 3 years ago

I've moved the case of the color picker not working after local edits to https://github.com/flutter/flutter-intellij/issues/5796