Skip to content

Commit 81ff06c

Browse files
committed
refactor(app): update AdNavigatorObserver initialization and remove stream subscription
- Remove unused import 'dart:async' - Update AdNavigatorObserver to use a state provider instead of appBloc - Remove interstitial ad stream subscription logic
1 parent 7312b71 commit 81ff06c

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

lib/app/view/app.dart

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import 'package:flutter_news_app_mobile_client_full_source_code/status/view/view
1919
import 'package:go_router/go_router.dart';
2020
import 'package:kv_storage_service/kv_storage_service.dart';
2121
import 'package:ui_kit/ui_kit.dart';
22-
import 'dart:async';
2322

2423
class App extends StatelessWidget {
2524
const App({
@@ -172,8 +171,6 @@ class _AppViewState extends State<_AppView> {
172171
AppStatusService? _appStatusService;
173172
// The observer for handling interstitial ads on route changes.
174173
AdNavigatorObserver? _adNavigatorObserver;
175-
// Stream subscription for interstitial ad signals from AppBloc.
176-
StreamSubscription<void>? _interstitialAdSubscription;
177174

178175
@override
179176
void initState() {
@@ -196,17 +193,11 @@ class _AppViewState extends State<_AppView> {
196193

197194
// Initialize AdNavigatorObserver.
198195
_adNavigatorObserver = AdNavigatorObserver(
199-
appBloc: appBloc,
196+
appStateProvider: () => context.read<AppBloc>().state,
200197
adService: widget.adService,
201198
adThemeStyle: adThemeStyle,
202199
);
203200

204-
// Subscribe to the AppBloc's interstitial ad stream.
205-
_interstitialAdSubscription =
206-
appBloc.showInterstitialAdStream.listen((_) {
207-
_adNavigatorObserver?.showInterstitialAd();
208-
});
209-
210201
_router = createRouter(
211202
authStatusNotifier: _statusNotifier,
212203
authenticationRepository: widget.authenticationRepository,
@@ -220,7 +211,6 @@ class _AppViewState extends State<_AppView> {
220211
userRepository: widget.userRepository,
221212
environment: widget.environment,
222213
adService: widget.adService,
223-
localAdRepository: widget.localAdRepository,
224214
adNavigatorObserver: _adNavigatorObserver!, // Pass the observer
225215
);
226216
}
@@ -230,8 +220,6 @@ class _AppViewState extends State<_AppView> {
230220
_statusNotifier.dispose();
231221
// Dispose the AppStatusService to cancel timers and remove observers.
232222
_appStatusService?.dispose();
233-
// Cancel the interstitial ad stream subscription.
234-
_interstitialAdSubscription?.cancel();
235223
// AdNavigatorObserver does not need explicit dispose here as it's a NavigatorObserver
236224
// and its internal resources are managed by the AdService/AdMob SDK.
237225
super.dispose();

0 commit comments

Comments
 (0)