@@ -17,18 +17,19 @@ class Config {
1717
1818 final Iterable <FieldConfig > _fields;
1919
20- Config (this .config, this .arguments, Iterable <FieldConfig > fields, this .extConfig): _fields = fields;
21-
22- factory Config .fromMap (
23- PlatformValueProvider valueProvider,
24- Map <dynamic , dynamic > config,
25- Map <dynamic , dynamic > args
26- ) {
27- final String devExtension = config[ConfigFieldType .DEV_EXTENSION ];
20+ Config (
21+ this .config, this .arguments, Iterable <FieldConfig > fields, this .extConfig)
22+ : _fields = fields;
23+
24+ factory Config .fromMap (PlatformValueProvider valueProvider,
25+ Map <dynamic , dynamic > config, Map <String , dynamic > args) {
26+ final String ? devExtension = config[ConfigFieldType .DEV_EXTENSION ];
2827 final Map <dynamic , dynamic > configFields = config[ConfigFieldType .FIELDS ];
29- final Map <dynamic , dynamic > extensions = config[ConfigFieldType .EXTENSIONS ] ?? {};
28+ final Map <dynamic , dynamic > extensions =
29+ config[ConfigFieldType .EXTENSIONS ] ?? {};
30+
3031 Map <dynamic , dynamic > extension = {};
31- String extensionName;
32+ String ? extensionName;
3233
3334 if (devExtension != null && args[devExtension]) {
3435 extensionName = devExtension;
@@ -44,40 +45,38 @@ class Config {
4445 extension = extensions[extensionName] ?? {};
4546 }
4647
47- Map <dynamic , dynamic > extensionFields = extension [ConfigFieldType .FIELDS ] ?? {};
48+ Map <dynamic , dynamic > extensionFields =
49+ extension [ConfigFieldType .FIELDS ] ?? {};
4850
49- final Iterable <FieldConfig > fields = configFields.keys
50- .map ((key) => FieldConfig (
51- valueProvider,
52- key,
53- config[ConfigFieldType .FIELDS ][key] ?? {},
54- extensionFields[key] ?? {},
55- args[key]
56- ));
51+ final Iterable <FieldConfig > fields = configFields.keys.map ((key) =>
52+ FieldConfig (
53+ valueProvider,
54+ key,
55+ config[ConfigFieldType .FIELDS ][key] ?? {},
56+ extensionFields[key] ?? {},
57+ args[key]));
5758
5859 return Config (config, args, fields, extension );
5960 }
6061
6162 /// Target file for generated config class
62- String get filePath {
63- return 'lib/${_getConfigValue (ConfigFieldType .PATH , 'environment_config.dart' )}' ;
64- }
63+ String get filePath =>
64+ 'lib/${_getConfigValue (ConfigFieldType .PATH , 'environment_config.dart' )}' ;
6565
6666 /// Target file for `.env` params
67- String get dotEnvFilePath {
68- return _getConfigValue (ConfigFieldType .DOTENV_PATH , '.env' );
69- }
67+ String get dotEnvFilePath =>
68+ _getConfigValue (ConfigFieldType .DOTENV_PATH , '.env' )! ;
7069
7170 /// Provides config class name
7271 String get className {
73- String className = _getConfigValue (ConfigFieldType .CLASS );
72+ String ? className = _getConfigValue (ConfigFieldType .CLASS );
7473
7574 if (className != null ) {
7675 return className;
7776 }
7877
7978 final String fileName =
80- RegExp (r'\/([\w_-]+)\.dart$' ).firstMatch (filePath).group (1 );
79+ RegExp (r'\/([\w_-]+)\.dart$' ).firstMatch (filePath)! .group (1 )! ;
8180
8281 return fileName
8382 .split ('_' )
@@ -86,20 +85,18 @@ class Config {
8685 }
8786
8887 /// Fields, that should be exported to `.env` file
89- Iterable <FieldConfig > get dotEnvFields {
90- return _fields.where ((field) => field.isDotEnv);
91- }
88+ Iterable <FieldConfig > get dotEnvFields =>
89+ _fields.where ((field) => field.isDotEnv);
9290
9391 /// Fields, that should be exported to Dart config file
94- Iterable <FieldConfig > get classConfigFields {
95- return _fields.where ((field) => field.isConfigField);
96- }
92+ Iterable <FieldConfig > get classConfigFields =>
93+ _fields.where ((field) => field.isConfigField);
9794
9895 /// Collection if imports, that should be added to config class
9996 Iterable <String > get imports => [
100- ...(config[ConfigFieldType .IMPORTS ]? .toList () ?? []),
101- ...(extConfig[ConfigFieldType .IMPORTS ]? .toList () ?? []),
102- ];
97+ ...(config[ConfigFieldType .IMPORTS ]? .toList () ?? []),
98+ ...(extConfig[ConfigFieldType .IMPORTS ]? .toList () ?? []),
99+ ];
103100
104101 /// If class should contain `const` constructor
105102 bool get isClassConst => config[ConfigFieldType .CONST ] ?? false ;
@@ -110,7 +107,7 @@ class Config {
110107 /// Defines if generator should try to create Dart config file
111108 bool get createConfigClass => classConfigFields.isNotEmpty;
112109
113- String _getConfigValue (key, [String defaultValue]) {
110+ String ? _getConfigValue (key, [String ? defaultValue]) {
114111 if (arguments.containsKey (key) && ! arguments[key].isEmpty) {
115112 return arguments[key];
116113 }
0 commit comments