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_Variables
generates:
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: EnvironmentVariables
should cause a Class named exactly that way to be generated in the appropriate file:
class EnvironmentVariables {
// SNIP!...
}
Steps to reproduce
- Install
dart_define as a dependency.
- Following the Dart Define package's documentation, use the information provided in the "Current Behaviour" section above to setup your
pubspec.yaml file.
- For this example, because I'm using "Flavors", ensure you have a
flavors:... section defined as specified in the usage instructions for dart_define.
- Assuming that you have a "Flavor" called "local", run
dart run dart_define generate --FLAVOR=local.
- The generated
*.gen.dart file (as specified by the dart_path option as specified by dart_define usage 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: someVar
results in:
static const somevar = // SNIP!...
and
dart_define:
variables:
- name: SOME_VAR
results in:
static const someVar = // SNIP!...
Platform
No response
Description
Current Behaviour
When we set the
class_nameoption fordart_defineinpubspec.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_nameshould beEnvironmentVariables, 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_nameto "Snake Case" (words separated by_"underscore" characters) and doing this causes the tool to generate the correct Class Name. E.g.:generates:
Expected Behaviour
If we set
class_nameinpubspec.yaml:define_dart.class_nameto a PascalCase string, the case should be retained and be output as the actual Class name in the generated*.gen.dartfile. E.g.:should cause a Class named exactly that way to be generated in the appropriate file:
Steps to reproduce
dart_defineas a dependency.pubspec.yamlfile.flavors:...section defined as specified in the usage instructions fordart_define.dart run dart_define generate --FLAVOR=local.*.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_nameoption insnake_casein order for it to be output in the correctPascalCaseformat.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
results in:
and
results in:
Platform
No response