You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
classEnvironmentVariables {
// 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:
classEnvironmentVariables {
// 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:
staticconst somevar =// SNIP!...
and
dart_define:
variables:
- name: SOME_VAR
results in:
staticconst someVar =// SNIP!...
Platform
No response
The text was updated successfully, but these errors were encountered:
Description
Current Behaviour
When we set the
class_name
option fordart_define
inpubspec.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 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_name
to "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_name
inpubspec.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.:should cause a Class named exactly that way to be generated in the appropriate file:
Steps to reproduce
dart_define
as a dependency.pubspec.yaml
file.flavors:...
section defined as specified in the usage instructions fordart_define
.dart run dart_define generate --FLAVOR=local
.*.gen.dart
file (as specified by thedart_path
option as specified bydart_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 insnake_case
in order for it to be output in the correctPascalCase
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
results in:
and
results in:
Platform
No response
The text was updated successfully, but these errors were encountered: