Skip to content

Commit 5909f85

Browse files
committed
refactor(ad): move InterstitialAdManager provider to after AppBloc
- Relocate InterstitialAdManager provider to ensure creation after AppBloc - Remove redundant comments - Adjust dispose method to remove explicit InterstitialAdManager disposal
1 parent 945a2e9 commit 5909f85

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/app/view/app.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,6 @@ class App extends StatelessWidget {
9090
RepositoryProvider.value(value: _kvStorageService),
9191
RepositoryProvider.value(value: _adService),
9292
RepositoryProvider.value(value: _localAdRepository),
93-
// Provide the InterstitialAdManager as a RepositoryProvider
94-
RepositoryProvider(
95-
create: (context) => InterstitialAdManager(
96-
appBloc: context.read<AppBloc>(),
97-
adService: context.read<AdService>(),
98-
),
99-
lazy: false, // Ensure it's created immediately
100-
),
10193
],
10294
child: MultiBlocProvider(
10395
providers: [
@@ -121,6 +113,16 @@ class App extends StatelessWidget {
121113
authenticationRepository: context.read<AuthRepository>(),
122114
),
123115
),
116+
// Provide the InterstitialAdManager as a RepositoryProvider
117+
// it depends on the state managed by AppBloc. Therefore,
118+
// so it must be created after AppBloc is available.
119+
RepositoryProvider(
120+
create: (context) => InterstitialAdManager(
121+
appBloc: context.read<AppBloc>(),
122+
adService: context.read<AdService>(),
123+
),
124+
lazy: false, // Ensure it's created immediately
125+
),
124126
],
125127
child: _AppView(
126128
authenticationRepository: _authenticationRepository,
@@ -220,8 +222,6 @@ class _AppViewState extends State<_AppView> {
220222
_statusNotifier.dispose();
221223
// Dispose the AppStatusService to cancel timers and remove observers.
222224
_appStatusService?.dispose();
223-
// Dispose the InterstitialAdManager
224-
context.read<InterstitialAdManager>().dispose();
225225
super.dispose();
226226
}
227227

0 commit comments

Comments
 (0)