Skip to content

Commit 40b9ead

Browse files
committed
feat(bootstrap): add demo data initializer service for demo environment
- Import DemoDataInitializerService from app/services - Instantiate DemoDataInitializerService conditionally for demo environment - Pass DemoDataInitializerService to App widget
1 parent 66998ea commit 40b9ead

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

lib/bootstrap.dart

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import 'package:flutter_news_app_mobile_client_full_source_code/ads/no_op_ad_pro
1616
import 'package:flutter_news_app_mobile_client_full_source_code/app/app.dart';
1717
import 'package:flutter_news_app_mobile_client_full_source_code/app/config/config.dart'
1818
as app_config;
19+
import 'package:flutter_news_app_mobile_client_full_source_code/app/services/demo_data_initializer_service.dart';
1920
import 'package:flutter_news_app_mobile_client_full_source_code/app/services/demo_data_migration_service.dart';
2021
import 'package:flutter_news_app_mobile_client_full_source_code/bloc_observer.dart';
2122
import 'package:flutter_news_app_mobile_client_full_source_code/shared/data/clients/country_inmemory_client.dart';
@@ -303,11 +304,21 @@ Future<Widget> bootstrap(
303304
// Conditionally instantiate DemoDataMigrationService
304305
final demoDataMigrationService =
305306
appConfig.environment == app_config.AppEnvironment.demo
306-
? DemoDataMigrationService(
307-
userAppSettingsRepository: userAppSettingsRepository,
308-
userContentPreferencesRepository: userContentPreferencesRepository,
309-
)
310-
: null;
307+
? DemoDataMigrationService(
308+
userAppSettingsRepository: userAppSettingsRepository,
309+
userContentPreferencesRepository: userContentPreferencesRepository,
310+
)
311+
: null;
312+
313+
// Conditionally instantiate DemoDataInitializerService
314+
final demoDataInitializerService =
315+
appConfig.environment == app_config.AppEnvironment.demo
316+
? DemoDataInitializerService(
317+
userAppSettingsRepository: userAppSettingsRepository,
318+
userContentPreferencesRepository: userContentPreferencesRepository,
319+
userRepository: userRepository,
320+
)
321+
: null;
311322

312323
return App(
313324
authenticationRepository: authenticationRepository,
@@ -322,6 +333,7 @@ Future<Widget> bootstrap(
322333
kvStorageService: kvStorage,
323334
environment: environment,
324335
demoDataMigrationService: demoDataMigrationService,
336+
demoDataInitializerService: demoDataInitializerService,
325337
adService: adService,
326338
initialUser: initialUser,
327339
);

0 commit comments

Comments
 (0)