5

I have created a flutter application and added a custom theme data (themes.dart)

Now everything works fine when I run it but I keep getting the error (Name non-constant identifiers using lowerCamelCase.)

I'm not really sure why it is complaining even though the application runs on my device. How do I fix this issue?

class CustomColors {
  // Must begin with lower-case character!
  final NovaWhite = Color(0xffecf0f1);  
}

ThemeData BaseThemeData() { // I get a complaint on BaseThemeData
  final ThemeData base = ThemeData.light();

  TextTheme _baseTextTheme(TextTheme base) {
    return base.copyWith(

      ),
    );
  }
}
Jaser
  • 245
  • 1
  • 7
  • 21
  • As it says use `novaWhite`, not `NovaWhite` and so on. By conventions non constant, non type identifiers should start with a lower case letter. It is only a style convention, so your code still runs – Paulw11 Mar 15 '20 at 22:34

4 Answers4

7

Name your variable like this

final novaWhite = Color(0xffecf0f1);
Erfan Eghterafi
  • 4,344
  • 1
  • 33
  • 44
5

This was a stupid mistake on my part as I did not understand why Visual Code was complaining.

(Name non-constant identifiers using lowerCamelCase.) - simply meant that the identifiers should have begun with a lower-case character.

// Must begin with lower-case character!
final NovaWhite = Color(0xffecf0f1);

Thanks to Paulw11 for the help!

Jaser
  • 245
  • 1
  • 7
  • 21
4
// ignore: non_constant_identifier_names 
final NovaWhite = Color(0xffecf0f1);

// ignore: non_constant_identifier_names 
final Nova_White = Color(0xffecf0f1);

// ignore: non_constant_identifier_names 
final nova_White = Color(0xffecf0f1);

// ignore: non_constant_identifier_names 
final nova_white = Color(0xffecf0f1);

.........................................................................................

// TRUE 
final novawhite = Color(0xffecf0f1);

// TRUE 
final novaWhite = Color(0xffecf0f1);
  • 3
    Generally, answers are much more helpful if they include an explanation of what the code is intended to do, and why that solves the problem without introducing others. – DCCoder May 18 '21 at 16:59
2

add this line in comment to ignore this

// ignore: non_constant_identifier_names
final NovaWhite = Color(0xffecf0f1);
prabhu r
  • 233
  • 2
  • 10
  • 16