Skip to content

Commit 7f49321

Browse files
committed
refactor(router): optimize adThemeStyle usage in router
- Introduce adThemeStyle variable to avoid multiple calls to Theme.of(context) - Apply the refactoring in multiple router pages
1 parent c72ff08 commit 7f49321

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/router/router.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ GoRouter createRouter({
276276
),
277277
);
278278
}
279+
final adThemeStyle = AdThemeStyle.fromTheme(Theme.of(context));
279280
return MultiBlocProvider(
280281
providers: [
281282
BlocProvider.value(value: accountBloc),
@@ -295,7 +296,7 @@ GoRouter createRouter({
295296
EntityDetailsLoadRequested(
296297
entityId: args.entityId,
297298
contentType: args.contentType,
298-
adThemeStyle: AdThemeStyle.fromTheme(Theme.of(context)),
299+
adThemeStyle: adThemeStyle,
299300
),
300301
),
301302
),
@@ -316,6 +317,7 @@ GoRouter createRouter({
316317
),
317318
);
318319
}
320+
final adThemeStyle = AdThemeStyle.fromTheme(Theme.of(context));
319321
return MultiBlocProvider(
320322
providers: [
321323
BlocProvider.value(value: accountBloc),
@@ -335,7 +337,7 @@ GoRouter createRouter({
335337
EntityDetailsLoadRequested(
336338
entityId: args.entityId,
337339
contentType: args.contentType,
338-
adThemeStyle: AdThemeStyle.fromTheme(Theme.of(context)),
340+
adThemeStyle: adThemeStyle,
339341
),
340342
),
341343
),
@@ -356,6 +358,7 @@ GoRouter createRouter({
356358
),
357359
);
358360
}
361+
final adThemeStyle = AdThemeStyle.fromTheme(Theme.of(context));
359362
return MultiBlocProvider(
360363
providers: [
361364
BlocProvider.value(value: accountBloc),
@@ -375,7 +378,7 @@ GoRouter createRouter({
375378
EntityDetailsLoadRequested(
376379
entityId: args.entityId,
377380
contentType: args.contentType,
378-
adThemeStyle: AdThemeStyle.fromTheme(Theme.of(context)),
381+
adThemeStyle: adThemeStyle,
379382
),
380383
),
381384
),

0 commit comments

Comments
 (0)