Skip to content

Commit

Permalink
refactor: fix analyzer issues
Browse files Browse the repository at this point in the history
  • Loading branch information
TesteurManiak committed Feb 17, 2025
1 parent 0bb2a12 commit f4c15b1
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 161 deletions.
7 changes: 2 additions & 5 deletions lib/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,14 @@ Future<void> bootstrap(FutureOr<Widget> Function() builder) async {
GoRouter.optionURLReflectsImperativeAPIs = true;

runApp(
UncontrolledProviderScope(
container: container,
child: await builder(),
),
UncontrolledProviderScope(container: container, child: await builder()),
);
}

class MyHttpOverrides extends HttpOverrides {
@override
HttpClient createHttpClient(SecurityContext? context) {
return super.createHttpClient(context)
..badCertificateCallback = (_, __, ___) => true;
..badCertificateCallback = (_, _, _) => true;
}
}
17 changes: 7 additions & 10 deletions lib/core/widgets/sliver_pull_to_refresh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class SliverPullToRefresh extends StatelessWidget {
refreshIndicatorExtent: 48,
refreshTriggerPullDistance: 64,
onRefresh: _handleRefresh,
builder: (_, refreshState, pulledExtent, refreshTriggerPullDistance, __) {
final percentageComplete =
(pulledExtent / refreshTriggerPullDistance).clamp(0.0, 1.0);
builder: (_, refreshState, pulledExtent, refreshTriggerPullDistance, _) {
final percentageComplete = (pulledExtent / refreshTriggerPullDistance)
.clamp(0.0, 1.0);

return Center(
child: Stack(
Expand Down Expand Up @@ -81,14 +81,11 @@ class _ActivityIndicator extends StatelessWidget {

return switch (refreshState) {
RefreshIndicatorMode.inactive ||
RefreshIndicatorMode.drag =>
const SizedBox.shrink(),
RefreshIndicatorMode.drag => const SizedBox.shrink(),
_ => Opacity(
opacity: opacityCurve.transform(progress),
child: const UnconstrainedBox(
child: RefreshProgressIndicator(),
),
),
opacity: opacityCurve.transform(progress),
child: const UnconstrainedBox(child: RefreshProgressIndicator()),
),
};
}
}
16 changes: 8 additions & 8 deletions lib/features/chapter_viewer/views/chapter_viewer_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ class _ContentState extends ConsumerState<_Content> {
ChapterViewerLoaded(:final pages) when pages.isEmpty =>
const LoadingContent(),
ChapterViewerLoaded(:final chapter, :final pages) => _PageViewer(
chapter: chapter,
chapterController: chapterPageController,
pages: pages,
initialPage: widget.initialPage,
),
chapter: chapter,
chapterController: chapterPageController,
pages: pages,
initialPage: widget.initialPage,
),
ChapterViewerError() => ErrorContent(
onRetry: () => ref.read(provider.notifier).fetchPages(),
),
onRetry: () => ref.read(provider.notifier).fetchPages(),
),
},
);
}
Expand Down Expand Up @@ -189,7 +189,7 @@ class _PageViewer extends ConsumerWidget {
alignment: Alignment.bottomCenter,
child: ValueListenableBuilder<int>(
valueListenable: chapterController,
builder: (_, page, __) {
builder: (_, page, _) {
return Text('${page + 1}/${pages.length}');
},
),
Expand Down
27 changes: 9 additions & 18 deletions lib/features/chapter_viewer/widgets/chapter_page_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ class ChapterPageImage extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
if (chapter.downloaded) {
return _LocaleImage(
chapter: chapter,
page: page,
fit: fit,
);
return _LocaleImage(chapter: chapter, page: page, fit: fit);
}

final source = ref.watch(scopedMangaDatasourceProvider);
Expand All @@ -38,7 +34,7 @@ class ChapterPageImage extends ConsumerWidget {
fit: fit,
headers: source.getHeaders(),
progressIndicatorBuilder: (_, progress) => _LoadingPlaceholder(progress),
errorBuilder: (_, __, e, onRetry) => _Error(error: e, onRetry: onRetry),
errorBuilder: (_, _, e, onRetry) => _Error(error: e, onRetry: onRetry),
);
}
}
Expand All @@ -59,15 +55,16 @@ class _LocaleImage extends ConsumerWidget {
final documentsDir = ref.watch(applicationDocumentsDirectoryProvider);
return documentsDir.when(
data: (baseDir) {
final file =
File(page.getFullLocalPath(chapter.getFullLocalPath(baseDir)));
final file = File(
page.getFullLocalPath(chapter.getFullLocalPath(baseDir)),
);
return Image.file(
file,
fit: fit,
errorBuilder: (_, e, __) => _Error(error: e),
errorBuilder: (_, e, _) => _Error(error: e),
);
},
error: (e, __) => _Error(error: e),
error: (e, _) => _Error(error: e),
loading: () => const _LoadingPlaceholder(null),
);
}
Expand Down Expand Up @@ -111,20 +108,14 @@ class _Error extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
spacing: 32,
children: [
const Icon(
Icons.broken_image_rounded,
color: Colors.grey,
),
const Icon(Icons.broken_image_rounded, color: Colors.grey),
Text(
error.toString(),
textAlign: TextAlign.center,
style: const TextStyle(color: Colors.grey),
),
if (onRetry != null)
TextButton(
onPressed: onRetry,
child: Text(strings.generic_retry),
),
TextButton(onPressed: onRetry, child: Text(strings.generic_retry)),
],
),
);
Expand Down
26 changes: 9 additions & 17 deletions lib/features/chapter_viewer/widgets/chapter_viewer_bottom_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ChapterViewerBottomBar extends ConsumerWidget {
children: [
ValueListenableBuilder<int>(
valueListenable: chapterController,
builder: (_, page, __) {
builder: (_, page, _) {
return _Slider(
totalPages: pageNumber,
chapterController: chapterController,
Expand All @@ -41,10 +41,9 @@ class ChapterViewerBottomBar extends ConsumerWidget {
IconButton(
icon: const Icon(Icons.settings_outlined),
onPressed: () {
ChapterSettingsBottomSheet(mangaId).show(
context,
isScrollControlled: true,
);
ChapterSettingsBottomSheet(
mangaId,
).show(context, isScrollControlled: true);
},
),
],
Expand All @@ -57,9 +56,7 @@ class ChapterViewerBottomBar extends ConsumerWidget {
}

class _UnconstrainedBottomBar extends StatelessWidget {
const _UnconstrainedBottomBar({
required this.child,
});
const _UnconstrainedBottomBar({required this.child});

final Widget child;

Expand All @@ -74,11 +71,9 @@ class _UnconstrainedBottomBar extends StatelessWidget {
color: bottomBarTheme.color ?? theme.colorScheme.surface,
child: SafeArea(
child: Padding(
padding: bottomBarTheme.padding ??
const EdgeInsets.symmetric(
vertical: 12,
horizontal: 16,
),
padding:
bottomBarTheme.padding ??
const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
child: child,
),
),
Expand All @@ -87,10 +82,7 @@ class _UnconstrainedBottomBar extends StatelessWidget {
}

class _Slider extends StatelessWidget {
const _Slider({
required this.totalPages,
required this.chapterController,
});
const _Slider({required this.totalPages, required this.chapterController});

final int totalPages;
final ChapterPageController chapterController;
Expand Down
32 changes: 7 additions & 25 deletions lib/features/details/navigation/route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ abstract class DetailsRoute extends GoRouteData {
);

if (isOnSourceRoute) {
SourceDetailsRoute(
mangaId: mangaId,
sourceId: sourceId,
).go(context);
SourceDetailsRoute(mangaId: mangaId, sourceId: sourceId).go(context);
return;
}

Expand All @@ -43,19 +40,13 @@ abstract class DetailsRoute extends GoRouteData {
Widget build(BuildContext context, GoRouterState state) {
return SourceProviderScope(
sourceId: sourceId,
child: DetailsView(
mangaId: mangaId,
openedFromSource: openedFromSource,
),
child: DetailsView(mangaId: mangaId, openedFromSource: openedFromSource),
);
}
}

class LibraryDetailsRoute extends DetailsRoute {
const LibraryDetailsRoute({
required this.sourceId,
required this.mangaId,
});
const LibraryDetailsRoute({required this.sourceId, required this.mangaId});

static const path = 'details/:sourceId/:mangaId';

Expand All @@ -67,10 +58,7 @@ class LibraryDetailsRoute extends DetailsRoute {
}

class SourceDetailsRoute extends DetailsRoute {
const SourceDetailsRoute({
required this.sourceId,
required this.mangaId,
});
const SourceDetailsRoute({required this.sourceId, required this.mangaId});

static const path = 'source-details/:mangaId';

Expand All @@ -86,10 +74,7 @@ class SourceDetailsRoute extends DetailsRoute {

@TypedGoRoute<CoverViewerRoute>(path: CoverViewerRoute.path)
class CoverViewerRoute extends GoRouteData {
const CoverViewerRoute({
required this.sourceId,
required this.coverUrl,
});
const CoverViewerRoute({required this.sourceId, required this.coverUrl});

final String sourceId;
final String coverUrl;
Expand All @@ -101,7 +86,7 @@ class CoverViewerRoute extends GoRouteData {
return CustomTransitionPage(
opaque: false,
fullscreenDialog: true,
transitionsBuilder: (_, __, ___, child) => child,
transitionsBuilder: (_, _, _, child) => child,
child: SourceProviderScope(
sourceId: sourceId,
child: CoverViewerView(coverUrl),
Expand All @@ -112,10 +97,7 @@ class CoverViewerRoute extends GoRouteData {

@TypedGoRoute<MangaWebviewRoute>(path: MangaWebviewRoute.path)
class MangaWebviewRoute extends GoRouteData {
const MangaWebviewRoute({
required this.sourceId,
required this.mangaId,
});
const MangaWebviewRoute({required this.sourceId, required this.mangaId});

final String sourceId;
final int mangaId;
Expand Down
Loading

0 comments on commit f4c15b1

Please sign in to comment.