-
-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Description
Current Behaviour
When we set the class_name option for dart_define in pubspec.yaml, the generated class name output does not respect appropriate Flutter Class Name case - which is UpperCamelCase/PascalCase.
For example, if I specify that class_name should be EnvironmentVariables, then the output Class name should, indeed, be exactly that - class EnvironmentVariables {...}. Instead, only the first letter in the Class name is capitalised, all following characters are lower case.
Additionally, though the documentation does not mention this, I tested setting the class_name to "Snake Case" (words separated by _ "underscore" characters) and doing this causes the tool to generate the correct Class Name. E.g.:
dart_define:
class_name: Environment_Variablesgenerates:
class EnvironmentVariables {
// SNIP!...
}Expected Behaviour
If we set class_name in pubspec.yaml:define_dart.class_name to a PascalCase string, the case should be retained and be output as the actual Class name in the generated *.gen.dart file. E.g.:
dart_define:
class_name: EnvironmentVariablesshould cause a Class named exactly that way to be generated in the appropriate file:
class EnvironmentVariables {
// SNIP!...
}Steps to reproduce
- Install
dart_defineas a dependency. - Following the Dart Define package's documentation, use the information provided in the "Current Behaviour" section above to setup your
pubspec.yamlfile. - For this example, because I'm using "Flavors", ensure you have a
flavors:...section defined as specified in the usage instructions fordart_define. - Assuming that you have a "Flavor" called "local", run
dart run dart_define generate --FLAVOR=local. - The generated
*.gen.dartfile (as specified by thedart_pathoption as specified bydart_defineusage instructions) will have a Class name who's name only has its first letter capitalised.
Free word
Suggestion
Maybe, to save on time, simply update the README / usage instructions to mention that it's necessary to specify the class_name option in snake_case in order for it to be output in the correct PascalCase format.
Additionally: It's important to note that the documentation should also be updated to specify that variable[{name}] values should ALSO be specified with snake_case because camelCase for these is also not respected at present.
Example
dart_define:
variables:
- name: someVarresults in:
static const somevar = // SNIP!...and
dart_define:
variables:
- name: SOME_VARresults in:
static const someVar = // SNIP!...Platform
No response