From 931664e6b67945d7cc3cab0bf7842a23a185cf16 Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Sat, 30 Sep 2023 18:33:04 +0600 Subject: [PATCH] refactor: migrate to catcher to catcher_2 --- lib/collections/routes.dart | 4 ++-- lib/components/library/user_local_tracks.dart | 6 +++--- lib/main.dart | 8 ++++---- lib/provider/download_manager_provider.dart | 6 +++--- .../proxy_playlist/proxy_playlist_provider.dart | 12 ++++++------ lib/provider/scrobbler_provider.dart | 4 ++-- lib/services/audio_player/audio_player.dart | 4 ++-- lib/services/audio_player/mk_state_player.dart | 6 +++--- .../download_manager/download_manager.dart | 4 ++-- lib/services/queries/album.dart | 4 ++-- lib/services/queries/playlist.dart | 4 ++-- lib/utils/duration.dart | 4 ++-- linux/flutter/generated_plugin_registrant.cc | 4 ---- linux/flutter/generated_plugins.cmake | 1 - macos/Flutter/GeneratedPluginRegistrant.swift | 2 -- pubspec.lock | 15 +++++++-------- pubspec.yaml | 4 +--- windows/flutter/generated_plugin_registrant.cc | 3 --- windows/flutter/generated_plugins.cmake | 1 - 19 files changed, 41 insertions(+), 55 deletions(-) diff --git a/lib/collections/routes.dart b/lib/collections/routes.dart index 0f83cf3e..ebdfb8bc 100644 --- a/lib/collections/routes.dart +++ b/lib/collections/routes.dart @@ -1,4 +1,4 @@ -import 'package:catcher/catcher.dart'; +import 'package:catcher_2/catcher_2.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:go_router/go_router.dart'; @@ -27,7 +27,7 @@ import 'package:spotube/pages/mobile_login/mobile_login.dart'; import '../pages/library/playlist_generate/playlist_generate_result.dart'; -final rootNavigatorKey = Catcher.navigatorKey; +final rootNavigatorKey = Catcher2.navigatorKey; final shellRouteNavigatorKey = GlobalKey(); final router = GoRouter( navigatorKey: rootNavigatorKey, diff --git a/lib/components/library/user_local_tracks.dart b/lib/components/library/user_local_tracks.dart index 16692462..11c19c4b 100644 --- a/lib/components/library/user_local_tracks.dart +++ b/lib/components/library/user_local_tracks.dart @@ -1,6 +1,6 @@ import 'dart:io'; -import 'package:catcher/catcher.dart'; +import 'package:catcher_2/catcher_2.dart'; import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -99,7 +99,7 @@ final localTracksProvider = FutureProvider>((ref) async { if (e is FfiException) { return {"file": f}; } - Catcher.reportCheckedError(e, stack); + Catcher2.reportCheckedError(e, stack); return {}; } }, @@ -123,7 +123,7 @@ final localTracksProvider = FutureProvider>((ref) async { return tracks; } catch (e, stack) { - Catcher.reportCheckedError(e, stack); + Catcher2.reportCheckedError(e, stack); return []; } }); diff --git a/lib/main.dart b/lib/main.dart index 595cc1e0..f8c3aa8c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,4 @@ -import 'package:catcher/catcher.dart'; +import 'package:catcher_2/catcher_2.dart'; import 'package:device_preview/device_preview.dart'; import 'package:fl_query/fl_query.dart'; import 'package:flutter/foundation.dart'; @@ -90,9 +90,9 @@ Future main(List rawArgs) async { path: hiveCacheDir, ); - Catcher( + Catcher2( enableLogger: arguments["verbose"], - debugConfig: CatcherOptions( + debugConfig: Catcher2Options( SilentReportMode(), [ ConsoleHandler( @@ -102,7 +102,7 @@ Future main(List rawArgs) async { if (!kIsWeb) FileHandler(await getLogsPath(), printLogs: false), ], ), - releaseConfig: CatcherOptions( + releaseConfig: Catcher2Options( SilentReportMode(), [ if (arguments["verbose"] ?? false) ConsoleHandler(), diff --git a/lib/provider/download_manager_provider.dart b/lib/provider/download_manager_provider.dart index bf92e9e0..46c7ee7e 100644 --- a/lib/provider/download_manager_provider.dart +++ b/lib/provider/download_manager_provider.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'dart:io'; -import 'package:catcher/catcher.dart'; +import 'package:catcher_2/catcher_2.dart'; import 'package:collection/collection.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; @@ -129,7 +129,7 @@ class DownloadManagerProvider extends ChangeNotifier { return Uint8List.fromList(bytes); } catch (e, stackTrace) { - Catcher.reportCheckedError(e, stackTrace); + Catcher2.reportCheckedError(e, stackTrace); return null; } } @@ -209,7 +209,7 @@ class DownloadManagerProvider extends ChangeNotifier { ); } } catch (e) { - Catcher.reportCheckedError(e, StackTrace.current); + Catcher2.reportCheckedError(e, StackTrace.current); continue; } } diff --git a/lib/provider/proxy_playlist/proxy_playlist_provider.dart b/lib/provider/proxy_playlist/proxy_playlist_provider.dart index 2650ab30..685a9942 100644 --- a/lib/provider/proxy_playlist/proxy_playlist_provider.dart +++ b/lib/provider/proxy_playlist/proxy_playlist_provider.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:math'; -import 'package:catcher/catcher.dart'; +import 'package:catcher_2/catcher_2.dart'; import 'package:collection/collection.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -98,7 +98,7 @@ class ProxyPlaylistNotifier extends PersistedStateNotifier updatePalette(); } catch (e, stackTrace) { - Catcher.reportCheckedError(e, stackTrace); + Catcher2.reportCheckedError(e, stackTrace); } }); @@ -117,7 +117,7 @@ class ProxyPlaylistNotifier extends PersistedStateNotifier active: newActiveIndex, ); } catch (e, stackTrace) { - Catcher.reportCheckedError(e, stackTrace); + Catcher2.reportCheckedError(e, stackTrace); } }); @@ -153,7 +153,7 @@ class ProxyPlaylistNotifier extends PersistedStateNotifier mapSourcesToTracks([audioPlayer.nextSource!]).firstOrNull; await removeTrack(oldTrack!.id!); } - Catcher.reportCheckedError(e, stackTrace); + Catcher2.reportCheckedError(e, stackTrace); } finally { isPreSearching.value = false; } @@ -210,7 +210,7 @@ class ProxyPlaylistNotifier extends PersistedStateNotifier } } } catch (e, stackTrace) { - Catcher.reportCheckedError(e, stackTrace); + Catcher2.reportCheckedError(e, stackTrace); } }); }(); @@ -602,7 +602,7 @@ class ProxyPlaylistNotifier extends PersistedStateNotifier return List.castFrom(segments); } catch (e, stack) { await SkipSegment.box.put(id, []); - Catcher.reportCheckedError(e, stack); + Catcher2.reportCheckedError(e, stack); return List.castFrom([]); } } diff --git a/lib/provider/scrobbler_provider.dart b/lib/provider/scrobbler_provider.dart index a41f722f..5ac3c5a1 100644 --- a/lib/provider/scrobbler_provider.dart +++ b/lib/provider/scrobbler_provider.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:catcher/catcher.dart'; +import 'package:catcher_2/catcher_2.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:scrobblenaut/scrobblenaut.dart'; import 'package:spotify/spotify.dart'; @@ -52,7 +52,7 @@ class ScrobblerNotifier extends PersistedStateNotifier { trackNumber: track.trackNumber, ); } catch (e, stackTrace) { - Catcher.reportCheckedError(e, stackTrace); + Catcher2.reportCheckedError(e, stackTrace); } }); } diff --git a/lib/services/audio_player/audio_player.dart b/lib/services/audio_player/audio_player.dart index 78dc149b..c944004c 100644 --- a/lib/services/audio_player/audio_player.dart +++ b/lib/services/audio_player/audio_player.dart @@ -1,4 +1,4 @@ -import 'package:catcher/catcher.dart'; +import 'package:catcher_2/catcher_2.dart'; import 'package:spotube/services/audio_player/mk_state_player.dart'; // import 'package:just_audio/just_audio.dart' as ja; import 'dart:async'; @@ -25,7 +25,7 @@ abstract class AudioPlayerInterface { // _justAudio = !_mkSupportedPlatform ? ja.AudioPlayer() : null { _mkPlayer.stream.error.listen((event) { - Catcher.reportCheckedError(event, StackTrace.current); + Catcher2.reportCheckedError(event, StackTrace.current); }); } diff --git a/lib/services/audio_player/mk_state_player.dart b/lib/services/audio_player/mk_state_player.dart index 148b95ac..91135756 100644 --- a/lib/services/audio_player/mk_state_player.dart +++ b/lib/services/audio_player/mk_state_player.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:catcher/catcher.dart'; +import 'package:catcher_2/catcher_2.dart'; import 'package:collection/collection.dart'; import 'package:media_kit/media_kit.dart'; // ignore: implementation_imports @@ -53,7 +53,7 @@ class MkPlayerWithState extends Player { await Future.delayed(const Duration(milliseconds: 250), play); } } catch (e, stackTrace) { - Catcher.reportCheckedError(e, stackTrace); + Catcher2.reportCheckedError(e, stackTrace); } }), stream.playlist.listen((event) { @@ -62,7 +62,7 @@ class MkPlayerWithState extends Player { } }), stream.error.listen((event) { - Catcher.reportCheckedError('[MediaKitError] \n$event', null); + Catcher2.reportCheckedError('[MediaKitError] \n$event', null); }), ]; } diff --git a/lib/services/download_manager/download_manager.dart b/lib/services/download_manager/download_manager.dart index 7af3655e..904f06cf 100644 --- a/lib/services/download_manager/download_manager.dart +++ b/lib/services/download_manager/download_manager.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'dart:collection'; import 'dart:io'; -import 'package:catcher/core/catcher.dart'; +import 'package:catcher_2/catcher_2.dart'; import 'package:collection/collection.dart'; import 'package:dio/dio.dart'; @@ -130,7 +130,7 @@ class DownloadManager { } } } catch (e, stackTrace) { - Catcher.reportCheckedError(e, stackTrace); + Catcher2.reportCheckedError(e, stackTrace); var task = getDownload(url)!; if (task.status.value != DownloadStatus.canceled && diff --git a/lib/services/queries/album.dart b/lib/services/queries/album.dart index f9e83ba3..53fcaf86 100644 --- a/lib/services/queries/album.dart +++ b/lib/services/queries/album.dart @@ -1,4 +1,4 @@ -import 'package:catcher/catcher.dart'; +import 'package:catcher_2/catcher_2.dart'; import 'package:fl_query/fl_query.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; @@ -71,7 +71,7 @@ class AlbumQueries { return albums; } catch (e, stack) { - Catcher.reportCheckedError(e, stack); + Catcher2.reportCheckedError(e, stack); rethrow; } }, diff --git a/lib/services/queries/playlist.dart b/lib/services/queries/playlist.dart index 16d9d079..ac8dc73f 100644 --- a/lib/services/queries/playlist.dart +++ b/lib/services/queries/playlist.dart @@ -1,4 +1,4 @@ -import 'package:catcher/catcher.dart'; +import 'package:catcher_2/catcher_2.dart'; import 'package:fl_query/fl_query.dart'; import 'package:fl_query_hooks/fl_query_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; @@ -221,7 +221,7 @@ class PlaylistQueries { await spotify.playlists.featured.getPage(5, pageParam); return playlists; } catch (e, stack) { - Catcher.reportCheckedError(e, stack); + Catcher2.reportCheckedError(e, stack); rethrow; } }, diff --git a/lib/utils/duration.dart b/lib/utils/duration.dart index 858503fb..35678a96 100644 --- a/lib/utils/duration.dart +++ b/lib/utils/duration.dart @@ -1,4 +1,4 @@ -import 'package:catcher/catcher.dart'; +import 'package:catcher_2/catcher_2.dart'; /// Parses duration string formatted by Duration.toString() to [Duration]. /// The string should be of form hours:minutes:seconds.microseconds @@ -53,7 +53,7 @@ Duration? tryParseDuration(String input) { try { return parseDuration(input); } catch (e, stack) { - Catcher.reportCheckedError(e, stack); + Catcher2.reportCheckedError(e, stack); return null; } } diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 9f8f2fd3..d455dc02 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,7 +6,6 @@ #include "generated_plugin_registrant.h" -#include #include #include #include @@ -19,9 +18,6 @@ #include void fl_register_plugins(FlPluginRegistry* registry) { - g_autoptr(FlPluginRegistrar) catcher_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "CatcherPlugin"); - catcher_plugin_register_with_registrar(catcher_registrar); g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); file_selector_plugin_register_with_registrar(file_selector_linux_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index c7f0e848..22319e92 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,7 +3,6 @@ # list(APPEND FLUTTER_PLUGIN_LIST - catcher file_selector_linux flutter_secure_storage_linux local_notifier diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 1010a6c4..270e6261 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,7 +7,6 @@ import Foundation import audio_service import audio_session -import catcher import device_info_plus import file_selector_macos import flutter_secure_storage_macos @@ -27,7 +26,6 @@ import window_size func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { AudioServicePlugin.register(with: registry.registrar(forPlugin: "AudioServicePlugin")) AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin")) - CatcherPlugin.register(with: registry.registrar(forPlugin: "CatcherPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin")) diff --git a/pubspec.lock b/pubspec.lock index 17276274..f80b7203 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -257,15 +257,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.2" - catcher: + catcher_2: dependency: "direct main" description: - path: "." - ref: HEAD - resolved-ref: "354108cbfe75299e8dd25be521946b32c41f621d" - url: "https://github.com/ThexXTURBOXx/catcher" - source: git - version: "0.8.0" + name: catcher_2 + sha256: "8a33bfa845de8aa4306e607d8c76a52b0f111576089f9f329270d56023900ad2" + url: "https://pub.dev" + source: hosted + version: "1.0.0-alpha.1" change_case: dependency: transitive description: @@ -2295,4 +2294,4 @@ packages: version: "2.0.2" sdks: dart: ">=3.1.0 <4.0.0" - flutter: ">=3.13.0" \ No newline at end of file + flutter: ">=3.13.0" diff --git a/pubspec.yaml b/pubspec.yaml index ec3fdd95..eebb5de9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -20,9 +20,7 @@ dependencies: auto_size_text: ^3.0.0 buttons_tabbar: ^1.3.6 cached_network_image: ^3.2.2 - catcher: - git: - url: https://github.com/ThexXTURBOXx/catcher + catcher_2: 1.0.0-alpha.1 collection: ^1.15.0 cupertino_icons: ^1.0.5 curved_navigation_bar: ^1.0.3 diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 089930d3..ff25c4e3 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,7 +6,6 @@ #include "generated_plugin_registrant.h" -#include #include #include #include @@ -20,8 +19,6 @@ #include void RegisterPlugins(flutter::PluginRegistry* registry) { - CatcherPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("CatcherPlugin")); FileSelectorWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("FileSelectorWindows")); FlutterSecureStorageWindowsPluginRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index b2b08c8e..0a5ab976 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,7 +3,6 @@ # list(APPEND FLUTTER_PLUGIN_LIST - catcher file_selector_windows flutter_secure_storage_windows local_notifier