@@ -132,14 +132,15 @@ class RemoteDefinitionProvider extends DefinitionProvider {
132
132
: super (i18nProps, cacheEnabled: cacheEnabled);
133
133
final String path;
134
134
final String appHome;
135
+ UserAppConfig ? appConfig;
135
136
FlutterI18nDelegate ? _i18nDelegate;
136
137
137
138
@override
138
139
FlutterI18nDelegate getI18NDelegate ({Locale ? forcedLocale}) {
139
140
_i18nDelegate ?? = FlutterI18nDelegate (
140
141
translationLoader: NetworkFileTranslationLoader (
141
142
baseUri: Uri .parse (i18nProps.path),
142
- forcedLocale: forcedLocale,
143
+ forcedLocale: forcedLocale ?? Locale (i18nProps.defaultLocale) ,
143
144
fallbackFile: i18nProps.fallbackLocale,
144
145
useCountryCode: i18nProps.useCountryCode,
145
146
decodeStrategies: [YamlDecodeStrategy ()]));
@@ -172,12 +173,31 @@ class RemoteDefinitionProvider extends DefinitionProvider {
172
173
173
174
@override
174
175
Future <AppBundle > getAppBundle ({bool ? bypassCache = false }) async {
176
+ final env = await _readJsonFile ('appConfig.json' );
177
+ if (env != null ) {
178
+ appConfig = UserAppConfig (
179
+ baseUrl: path,
180
+ envVariables: env as Map <String , dynamic >,
181
+ );
182
+ }
175
183
return AppBundle (
176
- theme: await _readFile ('theme.ensemble' ),
177
- resources: await _readFile ('resources.ensemble' ));
184
+ theme: await _readYamlFile ('theme.ensemble' ),
185
+ resources: await _readYamlFile ('resources.ensemble' ));
178
186
}
179
187
180
- Future <YamlMap ?> _readFile (String file) async {
188
+ Future <Map ?> _readJsonFile (String file) async {
189
+ http.Response response = await http.get (Uri .parse (path + file));
190
+ try {
191
+ if (response.statusCode == 200 ) {
192
+ return json.decode (response.body);
193
+ }
194
+ } catch (e) {
195
+ // ignore
196
+ }
197
+ return null ;
198
+ }
199
+
200
+ Future <YamlMap ?> _readYamlFile (String file) async {
181
201
try {
182
202
http.Response response = await http.get (Uri .parse (path + file));
183
203
if (response.statusCode == 200 ) {
@@ -189,16 +209,14 @@ class RemoteDefinitionProvider extends DefinitionProvider {
189
209
return null ;
190
210
}
191
211
192
- // TODO: to be implemented
193
212
@override
194
213
UserAppConfig ? getAppConfig () {
195
- return null ;
214
+ return appConfig ;
196
215
}
197
216
198
- // TODO: to be implemented
199
217
@override
200
218
Map <String , String > getSecrets () {
201
- return < String , String > {} ;
219
+ return dotenv.env ;
202
220
}
203
221
}
204
222
0 commit comments