@@ -132,14 +132,15 @@ class RemoteDefinitionProvider extends DefinitionProvider {
132132 : super (i18nProps, cacheEnabled: cacheEnabled);
133133 final String path;
134134 final String appHome;
135+ UserAppConfig ? appConfig;
135136 FlutterI18nDelegate ? _i18nDelegate;
136137
137138 @override
138139 FlutterI18nDelegate getI18NDelegate ({Locale ? forcedLocale}) {
139140 _i18nDelegate ?? = FlutterI18nDelegate (
140141 translationLoader: NetworkFileTranslationLoader (
141142 baseUri: Uri .parse (i18nProps.path),
142- forcedLocale: forcedLocale,
143+ forcedLocale: forcedLocale ?? Locale (i18nProps.defaultLocale) ,
143144 fallbackFile: i18nProps.fallbackLocale,
144145 useCountryCode: i18nProps.useCountryCode,
145146 decodeStrategies: [YamlDecodeStrategy ()]));
@@ -172,12 +173,31 @@ class RemoteDefinitionProvider extends DefinitionProvider {
172173
173174 @override
174175 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+ }
175183 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' ));
178186 }
179187
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 {
181201 try {
182202 http.Response response = await http.get (Uri .parse (path + file));
183203 if (response.statusCode == 200 ) {
@@ -189,16 +209,14 @@ class RemoteDefinitionProvider extends DefinitionProvider {
189209 return null ;
190210 }
191211
192- // TODO: to be implemented
193212 @override
194213 UserAppConfig ? getAppConfig () {
195- return null ;
214+ return appConfig ;
196215 }
197216
198- // TODO: to be implemented
199217 @override
200218 Map <String , String > getSecrets () {
201- return < String , String > {} ;
219+ return dotenv.env ;
202220 }
203221}
204222
0 commit comments