Closed binarypie closed 4 years ago
so the case here is that YAML treats with key values as Strings aways. So this
'http://__VALUE__'
will be equals to this
http://__VALUE__
For string fields default pattern is "'__VALUE__'"
. So in order to get the expected result your pattern should be following "'https://__VALUE__'"
. In that way '
will become part of the value and not opening/closing bracket of the String.
environment_config:
path: environment.dart
class: Environment
fields:
api:
type: String
short_name: a
pattern: "'https://__VALUE__'"
env_var: API_DOMAIN
The reason why I don't always add '
around field values is that I wanted to give dev an option to provide patterns to specify different types of values.
======= Here are some examples. ========
You may want to have something, that provides Strings value based on env
value:
class SomeValueProvider {
static String getSomeValue(String env) {
....
}
}
In that way, your YAML will look like this:
environment_config:
fields:
env:
type: String
pattern: SomeValueProvider.getSomeValue('__VALUE__')
Another example. You may want to have different classes:
class ProdClass {
static String getSomeValue() {
....
}
}
class DevClass {
static String getSomeValue() {
....
}
}
In that way, your YAML will look like this:
environment_config:
fields:
env:
type: String
pattern: __VALUE__Class.getSomeValue()
Hope it helps)
This is a great explanation. Thank you!
I understand that these examples are raw) I just wanted to show some probable use cases of my decision to don't always wrap result values)
Perhaps I am doing something incorrect here.
Set your environment variable(s)
Then run
Dartfmt will fail because of invalid syntax.
As a work around the following works as expected.