Skip to content

Color Preview in VSCode is fooled when using custom classes ending with "Colors". #2857

@HosseinYousefi

Description

@HosseinYousefi

Describe the bug
If the name of the class finishes with Colors, VSCode shows a preview as if the class name was Colors. (see the screenshot)

To Reproduce
You can use this code:

import 'dart:ui';

class MyColors {
  static const red = Color(0xff00ff00);
}

class NoColorHere {
  static const red = Color(0xff00ff00);
}

void somefunction() {
  final someOtherColor = NoColorHere.red;
  final someColor = MyColors.red;
}

Expected behavior
Preferably it should show the actual color in all cases, but a quick fix could be to not show the color preview when the class is not "Colors".

Screenshots
Screenshot 2020-10-08 at 10 49 29

Versions (please complete the following information):

  • VS Code version: 1.49.3
  • Dart extension version: 3.15.0
  • Dart/Flutter SDK version: 2.8.4/Flutter 1.17.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin flutterRelates to running Flutter appsis bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions