Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Fix analyzer warnings

Barnabasabd35e558215
diff --git a/lib/providers/_lp_core.dart b/lib/providers/_lp_core.dart
index 59f6151a..c67bf353 100644
--- a/lib/providers/_lp_core.dart
+++ b/lib/providers/_lp_core.dart
@@ -791,7 +791,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
auth.clearLocalOverride();
_localProbeFailures = 0;
} else {
- debugPrint('[Library] Local probe miss ${_localProbeFailures}/$_localProbeFailuresToFlip');
+ debugPrint('[Library] Local probe miss $_localProbeFailures/$_localProbeFailuresToFlip');
}
}
} else if (reachable) {
diff --git a/lib/providers/_lp_state.dart b/lib/providers/_lp_state.dart
index 8f2b9bbf..87f1c853 100644
--- a/lib/providers/_lp_state.dart
+++ b/lib/providers/_lp_state.dart
@@ -293,26 +293,6 @@ mixin _StateMixin on ChangeNotifier {
return cached;
}
- static bool _isLocalUrl(String url) {
- final uri = Uri.tryParse(url);
- if (uri == null || uri.host.isEmpty) return false;
- final host = uri.host.toLowerCase();
- if (host == 'localhost' || host == '127.0.0.1' || host == '::1') {
- return true;
- }
- final parts = host.split('.');
- if (parts.length == 4) {
- final a = int.tryParse(parts[0]);
- final b = int.tryParse(parts[1]);
- if (a == 10) return true;
- if (a == 172 && b != null && b >= 16 && b <= 31) return true;
- if (a == 192 && b == 168) return true;
- }
- if (host.endsWith('.local')) return true;
- if (host.endsWith('.ts.net')) return true;
- return false;
- }
-
void _showRollingSnackBar(String message) {
scaffoldMessengerKey.currentState
?..clearSnackBars()
diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart
index c79b0574..c9fcfa28 100644
--- a/lib/screens/home_screen.dart
+++ b/lib/screens/home_screen.dart
@@ -594,7 +594,7 @@ class HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMi
sectionIcon = Icons.collections_bookmark_rounded;
} else if (id.startsWith('genre:')) {
sectionIcon = Icons.label_outline_rounded;
- final sectionLabel = label as String;
+ final sectionLabel = label;
titleTap = () => SectionDetailSheet.show(
context,
title: sectionLabel,
@@ -607,7 +607,7 @@ class HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMi
// Author/series sections don't have book-shaped entities,
// so skip the book-oriented SectionDetailSheet for them.
if (type != 'authors' && type != 'series') {
- final sectionLabel = label as String;
+ final sectionLabel = label;
titleTap = () => SectionDetailSheet.show(
context,
title: sectionLabel,
@@ -716,8 +716,8 @@ class _ContinueListeningCardState extends State<_ContinueListeningCard> {
// copy of the cover (matches the absorbing card aesthetic). Both image()
// calls share the same cached bytes by URL.
return BlurPaddedCover(
- child: image(fit: BoxFit.contain),
blurChild: image(fit: BoxFit.cover),
+ child: image(fit: BoxFit.contain),
);
}
diff --git a/lib/services/audio_player_service.dart b/lib/services/audio_player_service.dart
index 86784efb..d87a91dc 100644
--- a/lib/services/audio_player_service.dart
+++ b/lib/services/audio_player_service.dart
@@ -1046,8 +1046,8 @@ class AudioPlayerService extends ChangeNotifier {
'stage=$stage',
'playing=${p?.playing}',
'state=${p?.processingState.name}',
- 'volume=${p?.volume?.toStringAsFixed(2)}',
- 'speed=${p?.speed?.toStringAsFixed(2)}',
+ 'volume=${p?.volume.toStringAsFixed(2)}',
+ 'speed=${p?.speed.toStringAsFixed(2)}',
'pos=${pos != null ? "${(pos.inMilliseconds / 1000.0).toStringAsFixed(1)}s" : "null"}',
'dur=${dur != null ? "${(dur.inMilliseconds / 1000.0).toStringAsFixed(1)}s" : "null"}',
'buf=${buffered != null ? "${(buffered.inMilliseconds / 1000.0).toStringAsFixed(1)}s" : "null"}',
diff --git a/lib/services/quick_actions_service.dart b/lib/services/quick_actions_service.dart
index 2bc67d35..1b1a6313 100644
--- a/lib/services/quick_actions_service.dart
+++ b/lib/services/quick_actions_service.dart
@@ -1,6 +1,5 @@
import 'dart:io';
-import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:quick_actions/quick_actions.dart';
diff --git a/lib/services/upcoming_releases_service.dart b/lib/services/upcoming_releases_service.dart
index db44bcca..830a5a8d 100644
--- a/lib/services/upcoming_releases_service.dart
+++ b/lib/services/upcoming_releases_service.dart
@@ -469,7 +469,6 @@ class UpcomingReleasesService extends ChangeNotifier {
static const _maxAsinAttempts = 5;
Future<String?> _resolveSeriesAsin(List<dynamic> books, String seriesName, int gen) async {
- int booksWithAsin = 0;
int audnexusAttempts = 0;
for (final book in books) {
if (_generation != gen) return null;
@@ -479,7 +478,6 @@ class UpcomingReleasesService extends ChangeNotifier {
final metadata = media['metadata'] as Map<String, dynamic>? ?? {};
final bookAsin = metadata['asin'] as String? ?? '';
if (bookAsin.isEmpty) continue;
- booksWithAsin++;
if (audnexusAttempts >= _maxAsinAttempts) break;
audnexusAttempts++;
diff --git a/lib/widgets/absorbing_card.dart b/lib/widgets/absorbing_card.dart
index b707b743..d648e35d 100644
--- a/lib/widgets/absorbing_card.dart
+++ b/lib/widgets/absorbing_card.dart
@@ -669,19 +669,17 @@ class AbsorbingCardState extends State<AbsorbingCard> with AutomaticKeepAliveCli
// Cover image
_coverUrl != null
? _isLocalCover
- ? BlurPaddedCover(child: Image.file(File(_coverUrl!), fit: _rectangleCovers ? BoxFit.cover : BoxFit.contain,
- errorBuilder: (_, __, ___) => CoverPlaceholder(title: _title, author: _author)),
- blurChild: Image.file(File(_coverUrl!), fit: BoxFit.cover,
+ ? BlurPaddedCover(blurChild: Image.file(File(_coverUrl!), fit: BoxFit.cover,
errorBuilder: (_, __, ___) => const SizedBox.shrink()),
- enabled: !_rectangleCovers)
- : BlurPaddedCover(child: CachedNetworkImage(imageUrl: _coverUrl!, fit: _rectangleCovers ? BoxFit.cover : BoxFit.contain,
- httpHeaders: mediaHeaders,
- placeholder: (_, __) => CoverPlaceholder(title: _title, author: _author),
- errorWidget: (_, __, ___) => CoverPlaceholder(title: _title, author: _author)),
- blurChild: CachedNetworkImage(imageUrl: _coverUrl!, fit: BoxFit.cover,
+ enabled: !_rectangleCovers, child: Image.file(File(_coverUrl!), fit: _rectangleCovers ? BoxFit.cover : BoxFit.contain,
+ errorBuilder: (_, __, ___) => CoverPlaceholder(title: _title, author: _author)))
+ : BlurPaddedCover(blurChild: CachedNetworkImage(imageUrl: _coverUrl!, fit: BoxFit.cover,
httpHeaders: mediaHeaders,
errorWidget: (_, __, ___) => const SizedBox.shrink()),
- enabled: !_rectangleCovers)
+ enabled: !_rectangleCovers, child: CachedNetworkImage(imageUrl: _coverUrl!, fit: _rectangleCovers ? BoxFit.cover : BoxFit.contain,
+ httpHeaders: mediaHeaders,
+ placeholder: (_, __) => CoverPlaceholder(title: _title, author: _author),
+ errorWidget: (_, __, ___) => CoverPlaceholder(title: _title, author: _author)))
: CoverPlaceholder(title: _title, author: _author),
// Casting overlay
if (isCastingThis) ...[
diff --git a/lib/widgets/book_card.dart b/lib/widgets/book_card.dart
index fffc3897..6d64eba6 100644
--- a/lib/widgets/book_card.dart
+++ b/lib/widgets/book_card.dart
@@ -395,8 +395,8 @@ class _CoverImage extends StatelessWidget {
if (file.existsSync()) {
return BlurPaddedCover(
enabled: isSquare,
- child: Image.file(file, fit: effectiveFit, errorBuilder: (_, __, ___) => _placeholder()),
blurChild: Image.file(file, fit: BoxFit.cover, errorBuilder: (_, __, ___) => const SizedBox.shrink()),
+ child: Image.file(file, fit: effectiveFit, errorBuilder: (_, __, ___) => _placeholder()),
);
}
return _placeholder();
@@ -404,6 +404,12 @@ class _CoverImage extends StatelessWidget {
return BlurPaddedCover(
enabled: isSquare,
+ blurChild: CachedNetworkImage(
+ imageUrl: coverUrl!,
+ fit: BoxFit.cover,
+ httpHeaders: httpHeaders,
+ errorWidget: (_, __, ___) => const SizedBox.shrink(),
+ ),
child: CachedNetworkImage(
imageUrl: coverUrl!,
fit: effectiveFit,
@@ -411,12 +417,6 @@ class _CoverImage extends StatelessWidget {
placeholder: (_, __) => _placeholder(),
errorWidget: (_, __, ___) => _placeholder(),
),
- blurChild: CachedNetworkImage(
- imageUrl: coverUrl!,
- fit: BoxFit.cover,
- httpHeaders: httpHeaders,
- errorWidget: (_, __, ___) => const SizedBox.shrink(),
- ),
);
}
diff --git a/lib/widgets/book_detail_sheet.dart b/lib/widgets/book_detail_sheet.dart
index 1540bb13..dadc89ba 100644
--- a/lib/widgets/book_detail_sheet.dart
+++ b/lib/widgets/book_detail_sheet.dart
@@ -383,23 +383,23 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
child: _squareCovers
? (_coverUrl!.startsWith('/')
? BlurPaddedCover(
- child: Image.file(File(_coverUrl!), fit: BoxFit.contain,
- errorBuilder: (_, __, ___) => const SizedBox()),
blurChild: Image.file(File(_coverUrl!), fit: BoxFit.cover,
errorBuilder: (_, __, ___) => const SizedBox.shrink()),
+ child: Image.file(File(_coverUrl!), fit: BoxFit.contain,
+ errorBuilder: (_, __, ___) => const SizedBox()),
)
: BlurPaddedCover(
+ blurChild: CachedNetworkImage(
+ imageUrl: _coverUrl!, fit: BoxFit.cover,
+ httpHeaders: lib.mediaHeaders,
+ errorWidget: (_, __, ___) => const SizedBox.shrink(),
+ ),
child: CachedNetworkImage(
imageUrl: _coverUrl!, fit: BoxFit.contain,
httpHeaders: lib.mediaHeaders,
placeholder: (_, __) => const SizedBox(),
errorWidget: (_, __, ___) => const SizedBox(),
),
- blurChild: CachedNetworkImage(
- imageUrl: _coverUrl!, fit: BoxFit.cover,
- httpHeaders: lib.mediaHeaders,
- errorWidget: (_, __, ___) => const SizedBox.shrink(),
- ),
))
: CachedNetworkImage(
imageUrl: _coverUrl!, fit: BoxFit.contain,
diff --git a/lib/widgets/equalizer_sheet.dart b/lib/widgets/equalizer_sheet.dart
index aa099226..b0a0934e 100644
--- a/lib/widgets/equalizer_sheet.dart
+++ b/lib/widgets/equalizer_sheet.dart
@@ -53,7 +53,6 @@ class _EqualizerSheetContentState extends State<_EqualizerSheetContent> {
// and write edits back to that item's storage without touching the platform
// (which is still applying the playing book's EQ).
bool _previewMode = false;
- bool _previewLoaded = false;
bool _pEnabled = false;
String _pPreset = 'flat';
List<double> _pBands = [];
@@ -87,7 +86,6 @@ class _EqualizerSheetContentState extends State<_EqualizerSheetContent> {
&& widget.openedForItemId != _eq.currentItemId;
if (shouldPreview && !_previewMode) {
_previewMode = true;
- _previewLoaded = false;
// Seed the buffer so the UI has a valid shape (correct band count)
// until loadItemSnapshot returns. These defaults get overwritten
// once the real saved snapshot loads.
@@ -102,7 +100,6 @@ class _EqualizerSheetContentState extends State<_EqualizerSheetContent> {
_loadPreview();
} else if (!shouldPreview && _previewMode) {
_previewMode = false;
- _previewLoaded = false;
}
}
@@ -120,7 +117,6 @@ class _EqualizerSheetContentState extends State<_EqualizerSheetContent> {
_pMono = snap['mono'] as bool;
_pSkipSilence = snap['skipSilence'] as bool? ?? false;
_pBands = List<double>.from((snap['bands'] as List).cast<double>());
- _previewLoaded = true;
});
}
diff --git a/lib/widgets/expanded_card.dart b/lib/widgets/expanded_card.dart
index 525299a8..04b8470f 100644
--- a/lib/widgets/expanded_card.dart
+++ b/lib/widgets/expanded_card.dart
@@ -681,19 +681,17 @@ class _ExpandedCardState extends State<ExpandedCard> {
// Cover image
_coverUrl != null
? _isLocalCover
- ? BlurPaddedCover(child: Image.file(File(_coverUrl!), fit: _rectangleCovers ? BoxFit.cover : BoxFit.contain,
- errorBuilder: (_, __, ___) => CoverPlaceholder(title: _title, author: _author)),
- blurChild: Image.file(File(_coverUrl!), fit: BoxFit.cover,
+ ? BlurPaddedCover(blurChild: Image.file(File(_coverUrl!), fit: BoxFit.cover,
errorBuilder: (_, __, ___) => const SizedBox.shrink()),
- enabled: !_rectangleCovers)
- : BlurPaddedCover(child: CachedNetworkImage(imageUrl: _coverUrl!, fit: _rectangleCovers ? BoxFit.cover : BoxFit.contain,
- httpHeaders: mediaHeaders,
- placeholder: (_, __) => CoverPlaceholder(title: _title, author: _author),
- errorWidget: (_, __, ___) => CoverPlaceholder(title: _title, author: _author)),
- blurChild: CachedNetworkImage(imageUrl: _coverUrl!, fit: BoxFit.cover,
+ enabled: !_rectangleCovers, child: Image.file(File(_coverUrl!), fit: _rectangleCovers ? BoxFit.cover : BoxFit.contain,
+ errorBuilder: (_, __, ___) => CoverPlaceholder(title: _title, author: _author)))
+ : BlurPaddedCover(blurChild: CachedNetworkImage(imageUrl: _coverUrl!, fit: BoxFit.cover,
httpHeaders: mediaHeaders,
errorWidget: (_, __, ___) => const SizedBox.shrink()),
- enabled: !_rectangleCovers)
+ enabled: !_rectangleCovers, child: CachedNetworkImage(imageUrl: _coverUrl!, fit: _rectangleCovers ? BoxFit.cover : BoxFit.contain,
+ httpHeaders: mediaHeaders,
+ placeholder: (_, __) => CoverPlaceholder(title: _title, author: _author),
+ errorWidget: (_, __, ___) => CoverPlaceholder(title: _title, author: _author)))
: CoverPlaceholder(title: _title, author: _author),
// Play/pause overlay
if (_coverPlayButton && !isCastingThis && !isFinished)
diff --git a/lib/widgets/home_section.dart b/lib/widgets/home_section.dart
index 3cfb5998..1274935b 100644
--- a/lib/widgets/home_section.dart
+++ b/lib/widgets/home_section.dart
@@ -291,23 +291,23 @@ class _EpisodeCard extends StatelessWidget {
if (coverUrl != null)
coverUrl.startsWith('/')
? BlurPaddedCover(
+ blurChild: Image.file(File(coverUrl), fit: BoxFit.cover,
+ errorBuilder: (_, __, ___) => const SizedBox.shrink()),
child: Image.file(File(coverUrl), fit: BoxFit.contain,
errorBuilder: (_, __, ___) => Container(
color: cs.surfaceContainerHigh,
child: Icon(Icons.podcasts_rounded, size: 32,
- color: cs.onSurfaceVariant.withValues(alpha: 0.3)))),
- blurChild: Image.file(File(coverUrl), fit: BoxFit.cover,
- errorBuilder: (_, __, ___) => const SizedBox.shrink()))
+ color: cs.onSurfaceVariant.withValues(alpha: 0.3)))))
: BlurPaddedCover(
+ blurChild: Image.network(coverUrl, fit: BoxFit.cover,
+ headers: lib.mediaHeaders,
+ errorBuilder: (_, __, ___) => const SizedBox.shrink()),
child: Image.network(coverUrl, fit: BoxFit.contain,
headers: lib.mediaHeaders,
errorBuilder: (_, __, ___) => Container(
color: cs.surfaceContainerHigh,
child: Icon(Icons.podcasts_rounded, size: 32,
- color: cs.onSurfaceVariant.withValues(alpha: 0.3)))),
- blurChild: Image.network(coverUrl, fit: BoxFit.cover,
- headers: lib.mediaHeaders,
- errorBuilder: (_, __, ___) => const SizedBox.shrink()))
+ color: cs.onSurfaceVariant.withValues(alpha: 0.3)))))
else
Container(
color: cs.surfaceContainerHigh,
diff --git a/lib/widgets/library_grid_tiles.dart b/lib/widgets/library_grid_tiles.dart
index ccea1ddb..d285f0b2 100644
--- a/lib/widgets/library_grid_tiles.dart
+++ b/lib/widgets/library_grid_tiles.dart
@@ -276,18 +276,18 @@ class _GridBookTileState extends State<GridBookTile> {
}
if (coverUrl.startsWith('/')) {
return BlurPaddedCover(
- child: Image.file(File(coverUrl), fit: BoxFit.contain,
- errorBuilder: (_, __, ___) => placeholder),
blurChild: Image.file(File(coverUrl), fit: BoxFit.cover,
errorBuilder: (_, __ ,___) => const SizedBox.shrink()),
+ child: Image.file(File(coverUrl), fit: BoxFit.contain,
+ errorBuilder: (_, __, ___) => placeholder),
);
}
return BlurPaddedCover(
+ blurChild: CachedNetworkImage(imageUrl: coverUrl, fit: BoxFit.cover,
+ httpHeaders: headers, errorWidget: (_, __, ___) => const SizedBox.shrink()),
child: CachedNetworkImage(imageUrl: coverUrl, fit: BoxFit.contain,
httpHeaders: headers, placeholder: (_, __) => placeholder,
errorWidget: (_, __, ___) => placeholder),
- blurChild: CachedNetworkImage(imageUrl: coverUrl, fit: BoxFit.cover,
- httpHeaders: headers, errorWidget: (_, __, ___) => const SizedBox.shrink()),
);
}
}