Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix - Name non-constant identifiers using lowerCamelCase

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(

      ),
    );
  }
}
like image 821
Jaser Avatar asked Dec 08 '22 10:12

Jaser


2 Answers

Name your variable like this

final novaWhite = Color(0xffecf0f1);
like image 155
Erfan Eghterafi Avatar answered Dec 28 '22 07:12

Erfan Eghterafi


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!

like image 28
Jaser Avatar answered Dec 28 '22 08:12

Jaser