How to fix - Name non-constant identifiers using lowerCamelCase

Viewed 14480

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(

      ),
    );
  }
}
4 Answers

Name your variable like this

final novaWhite = Color(0xffecf0f1);

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!

// 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);

add this line in comment to ignore this

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