Skip to content

Commit 6d0ae00

Browse files
committed
lint: misc
1 parent 721f8b8 commit 6d0ae00

File tree

6 files changed

+50
-58
lines changed

6 files changed

+50
-58
lines changed

lib/ads/interstitial_ad_manager.dart

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ class InterstitialAdManager {
2626
required AppBloc appBloc,
2727
required AdService adService,
2828
Logger? logger,
29-
}) : _appBloc = appBloc,
30-
_adService = adService,
31-
_logger = logger ?? Logger('InterstitialAdManager') {
29+
}) : _appBloc = appBloc,
30+
_adService = adService,
31+
_logger = logger ?? Logger('InterstitialAdManager') {
3232
// Listen to the AppBloc stream to react to state changes.
3333
_appBlocSubscription = _appBloc.stream.listen(_onAppStateChanged);
3434
// Initialize with the current state.
@@ -67,9 +67,7 @@ class InterstitialAdManager {
6767
// If the ad config or user role has changed, update internal state
6868
// and potentially pre-load a new ad.
6969
if (newAdConfig != _adConfig || newUserRole != _userRole) {
70-
_logger.info(
71-
'Ad config or user role changed. Updating internal state.',
72-
);
70+
_logger.info('Ad config or user role changed. Updating internal state.');
7371
_adConfig = newAdConfig;
7472
_userRole = newUserRole;
7573
// A config change might mean we need to load an ad now.
@@ -102,21 +100,23 @@ class InterstitialAdManager {
102100
final brightness = appState.themeMode == ThemeMode.system
103101
? SchedulerBinding.instance.window.platformBrightness
104102
: (appState.themeMode == ThemeMode.dark
105-
? Brightness.dark
106-
: Brightness.light);
103+
? Brightness.dark
104+
: Brightness.light);
107105

108106
// Create a ThemeData instance from the AppState's settings.
109107
// This allows us to derive AdThemeStyle without a BuildContext.
110108
final themeData = brightness == Brightness.light
111109
? lightTheme(
112110
scheme: appState.flexScheme,
113-
appTextScaleFactor: appState.settings.displaySettings.textScaleFactor,
111+
appTextScaleFactor:
112+
appState.settings.displaySettings.textScaleFactor,
114113
appFontWeight: appState.settings.displaySettings.fontWeight,
115114
fontFamily: appState.settings.displaySettings.fontFamily,
116115
)
117116
: darkTheme(
118117
scheme: appState.flexScheme,
119-
appTextScaleFactor: appState.settings.displaySettings.textScaleFactor,
118+
appTextScaleFactor:
119+
appState.settings.displaySettings.textScaleFactor,
120120
appFontWeight: appState.settings.displaySettings.fontWeight,
121121
fontFamily: appState.settings.displaySettings.fontFamily,
122122
);
@@ -170,7 +170,8 @@ class InterstitialAdManager {
170170
if (requiredTransitions > 0 && _transitionCount >= requiredTransitions) {
171171
_logger.info('Transition count meets threshold. Attempting to show ad.');
172172
await _showAd(context);
173-
_transitionCount = 0; // Reset counter after showing (or attempting to show)
173+
_transitionCount =
174+
0; // Reset counter after showing (or attempting to show)
174175
} else {
175176
_logger.info(
176177
'Transition count ($_transitionCount) has not met threshold ($requiredTransitions).',
@@ -181,7 +182,9 @@ class InterstitialAdManager {
181182
/// Shows the pre-loaded interstitial ad.
182183
Future<void> _showAd(BuildContext context) async {
183184
if (_preloadedAd == null) {
184-
_logger.warning('Show ad called, but no ad is pre-loaded. Pre-loading now.');
185+
_logger.warning(
186+
'Show ad called, but no ad is pre-loaded. Pre-loading now.',
187+
);
185188
// Attempt a last-minute load if no ad is ready.
186189
await _maybePreloadAd(_appBloc.state);
187190
if (_preloadedAd == null) {
@@ -198,8 +201,10 @@ class InterstitialAdManager {
198201
case AdPlatformType.admob:
199202
await _showAdMobAd(adToShow);
200203
case AdPlatformType.local:
204+
// ignore: use_build_context_synchronously
201205
await _showLocalAd(context, adToShow);
202206
case AdPlatformType.demo:
207+
// ignore: use_build_context_synchronously
203208
await _showDemoAd(context);
204209
}
205210
} catch (e, s) {
@@ -208,35 +213,35 @@ class InterstitialAdManager {
208213
// After the ad is shown or fails to show, dispose of it and
209214
// start pre-loading the next one for the next opportunity.
210215
_disposePreloadedAd(); // Ensure the ad object is disposed
211-
_maybePreloadAd(_appBloc.state);
216+
unawaited(_maybePreloadAd(_appBloc.state));
212217
}
213218
}
214219

215220
Future<void> _showAdMobAd(InterstitialAd ad) async {
216221
if (ad.adObject is! admob.InterstitialAd) return;
217222
final admobAd = ad.adObject as admob.InterstitialAd
218-
219-
..fullScreenContentCallback = admob.FullScreenContentCallback(
220-
onAdShowedFullScreenContent: (ad) =>
221-
_logger.info('AdMob ad showed full screen.'),
222-
onAdDismissedFullScreenContent: (ad) {
223-
_logger.info('AdMob ad dismissed.');
224-
ad.dispose();
225-
},
226-
onAdFailedToShowFullScreenContent: (ad, error) {
227-
_logger.severe('AdMob ad failed to show: $error');
228-
ad.dispose();
229-
},
230-
);
223+
..fullScreenContentCallback = admob.FullScreenContentCallback(
224+
onAdShowedFullScreenContent: (ad) =>
225+
_logger.info('AdMob ad showed full screen.'),
226+
onAdDismissedFullScreenContent: (ad) {
227+
_logger.info('AdMob ad dismissed.');
228+
ad.dispose();
229+
},
230+
onAdFailedToShowFullScreenContent: (ad, error) {
231+
_logger.severe('AdMob ad failed to show: $error');
232+
ad.dispose();
233+
},
234+
);
231235
await admobAd.show();
232236
}
233237

234238
Future<void> _showLocalAd(BuildContext context, InterstitialAd ad) async {
235239
if (ad.adObject is! LocalInterstitialAd) return;
236240
await showDialog<void>(
237241
context: context,
238-
builder: (_) =>
239-
LocalInterstitialAdDialog(localInterstitialAd: ad.adObject as LocalInterstitialAd),
242+
builder: (_) => LocalInterstitialAdDialog(
243+
localInterstitialAd: ad.adObject as LocalInterstitialAd,
244+
),
240245
);
241246
}
242247

lib/app/bloc/app_bloc.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,13 @@ class AppBloc extends Bloc<AppEvent, AppState> {
240240
// Map language code to Locale
241241
final newLocale = Locale(userAppSettings.language.code);
242242

243-
_logger.info(
243+
_logger..info(
244244
'_onAppSettingsRefreshed: userAppSettings.fontFamily: ${userAppSettings.displaySettings.fontFamily}',
245-
);
246-
_logger.info(
245+
)
246+
..info(
247247
'_onAppSettingsRefreshed: userAppSettings.fontWeight: ${userAppSettings.displaySettings.fontWeight}',
248-
);
249-
_logger.info(
248+
)
249+
..info(
250250
'_onAppSettingsRefreshed: newFontFamily mapped to: $newFontFamily',
251251
);
252252

lib/bootstrap.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ 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';
2221
import 'package:flutter_news_app_mobile_client_full_source_code/ads/local_ad_provider.dart';
2322
import 'package:flutter_news_app_mobile_client_full_source_code/app/app.dart';
2423
import 'package:flutter_news_app_mobile_client_full_source_code/app/config/config.dart'
@@ -140,7 +139,7 @@ Future<Widget> bootstrap(
140139

141140
// Create a GlobalKey for the NavigatorState to be used by AppBloc
142141
// and InterstitialAdManager for BuildContext access.
143-
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
142+
final navigatorKey = GlobalKey<NavigatorState>();
144143

145144
// 4. Initialize all other DataClients and Repositories.
146145
// These now also have a guaranteed valid httpClient.

lib/headline-details/view/headline_details_page.dart

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,6 @@ class _HeadlineDetailsPageState extends State<HeadlineDetailsPage> {
313313
),
314314
),
315315
),
316-
];
317-
318-
slivers.addAll([
319316
SliverPadding(
320317
padding: horizontalPadding.copyWith(top: AppSpacing.lg),
321318
sliver: SliverToBoxAdapter(
@@ -339,7 +336,7 @@ class _HeadlineDetailsPageState extends State<HeadlineDetailsPage> {
339336
),
340337
),
341338
),
342-
]);
339+
];
343340

344341
// Add ad above continue reading button if configured
345342
if (adConfig != null &&
@@ -522,9 +519,9 @@ class _HeadlineDetailsPageState extends State<HeadlineDetailsPage> {
522519
..add(
523520
InkWell(
524521
onTap: () {
525-
context
526-
.read<InterstitialAdManager>()
527-
.onPotentialAdTrigger(context: context);
522+
context.read<InterstitialAdManager>().onPotentialAdTrigger(
523+
context: context,
524+
);
528525
context.pushNamed(
529526
Routes.entityDetailsName,
530527
pathParameters: {
@@ -553,9 +550,9 @@ class _HeadlineDetailsPageState extends State<HeadlineDetailsPage> {
553550
..add(
554551
InkWell(
555552
onTap: () {
556-
context
557-
.read<InterstitialAdManager>()
558-
.onPotentialAdTrigger(context: context);
553+
context.read<InterstitialAdManager>().onPotentialAdTrigger(
554+
context: context,
555+
);
559556
context.pushNamed(
560557
Routes.entityDetailsName,
561558
pathParameters: {
@@ -584,9 +581,9 @@ class _HeadlineDetailsPageState extends State<HeadlineDetailsPage> {
584581
..add(
585582
InkWell(
586583
onTap: () {
587-
context
588-
.read<InterstitialAdManager>()
589-
.onPotentialAdTrigger(context: context);
584+
context.read<InterstitialAdManager>().onPotentialAdTrigger(
585+
context: context,
586+
);
590587
context.pushNamed(
591588
Routes.entityDetailsName,
592589
pathParameters: {

lib/router/router.dart

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -795,15 +795,5 @@ class GoRouterObserver extends NavigatorObserver {
795795
/// The [GlobalKey] used to access the [NavigatorState].
796796
final GlobalKey<NavigatorState> navigatorKey;
797797

798-
@override
799-
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
800-
super.didPush(route, previousRoute);
801-
// You can add logging or other logic here if needed.
802-
}
803798

804-
@override
805-
void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
806-
super.didPop(route, previousRoute);
807-
// You can add logging or other logic here if needed.
808-
}
809799
}

lib/status/view/update_required_page.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class UpdateRequiredPage extends StatelessWidget {
3838
await launchUrl(uri, mode: LaunchMode.externalApplication);
3939
} else {
4040
// If the URL can't be launched, inform the user.
41+
// ignore: use_build_context_synchronously
4142
ScaffoldMessenger.of(context)
4243
..hideCurrentSnackBar()
4344
..showSnackBar(

0 commit comments

Comments
 (0)