Skip to content

Commit 38e5f4f

Browse files
committed
feat(ads): integrate InterstitialAdManager and navigatorKey in bootstrap
- Add import for InterstitialAdManager - Create GlobalKey<NavigatorState> for BuildContext access - Pass navigatorKey to App for use by AppBloc and InterstitialAdManager
1 parent a27f82c commit 38e5f4f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/bootstrap.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import 'package:flutter_news_app_mobile_client_full_source_code/ads/ad_service.d
1818
import 'package:flutter_news_app_mobile_client_full_source_code/ads/admob_ad_provider.dart'
1919
if (dart.library.io) 'package:flutter_news_app_mobile_client_full_source_code/ads/admob_ad_provider.dart';
2020
import 'package:flutter_news_app_mobile_client_full_source_code/ads/demo_ad_provider.dart';
21+
import 'package:flutter_news_app_mobile_client_full_source_code/ads/interstitial_ad_manager.dart';
2122
import 'package:flutter_news_app_mobile_client_full_source_code/ads/local_ad_provider.dart';
2223
import 'package:flutter_news_app_mobile_client_full_source_code/app/app.dart';
2324
import 'package:flutter_news_app_mobile_client_full_source_code/app/config/config.dart'
@@ -137,6 +138,10 @@ Future<Widget> bootstrap(
137138
// This ensures the AppBloc starts with an accurate authentication status.
138139
final initialUser = await authenticationRepository.getCurrentUser();
139140

141+
// Create a GlobalKey for the NavigatorState to be used by AppBloc
142+
// and InterstitialAdManager for BuildContext access.
143+
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
144+
140145
// 4. Initialize all other DataClients and Repositories.
141146
// These now also have a guaranteed valid httpClient.
142147
DataClient<Headline> headlinesClient;
@@ -417,5 +422,6 @@ Future<Widget> bootstrap(
417422
adService: adService,
418423
initialUser: initialUser,
419424
localAdRepository: localAdRepository,
425+
navigatorKey: navigatorKey, // Pass the navigatorKey to App
420426
);
421427
}

0 commit comments

Comments
 (0)