refactor(core): reduce generated and duplicate code

This commit is contained in:
zarzet
2026-08-30 11:57:47 +07:00
parent 7141ca980f
commit e931d5e2b0
23 changed files with 18 additions and 73100 deletions
-12
View File
@@ -216,16 +216,4 @@ class CacheStats {
final int totalSizeBytes;
const CacheStats({required this.fileCount, required this.totalSizeBytes});
String get formattedSize {
if (totalSizeBytes < 1024) {
return '$totalSizeBytes B';
} else if (totalSizeBytes < 1024 * 1024) {
return '${(totalSizeBytes / 1024).toStringAsFixed(1)} KB';
} else if (totalSizeBytes < 1024 * 1024 * 1024) {
return '${(totalSizeBytes / (1024 * 1024)).toStringAsFixed(1)} MB';
} else {
return '${(totalSizeBytes / (1024 * 1024 * 1024)).toStringAsFixed(2)} GB';
}
}
}
+2 -3
View File
@@ -4,6 +4,7 @@ import 'package:sqflite/sqflite.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:spotiflac_android/services/sqlite_helpers.dart' as sqlite;
import 'package:spotiflac_android/utils/isrc_utils.dart' as isrc;
import 'package:spotiflac_android/utils/logger.dart';
import 'package:spotiflac_android/utils/path_match_keys.dart';
@@ -286,9 +287,7 @@ class HistoryDatabase {
static String normalizeLookupText(String? value) =>
sqlite.normalizeLookupText(value);
static String normalizeIsrc(String? value) {
return (value ?? '').trim().toUpperCase().replaceAll(RegExp(r'[-\s]'), '');
}
static String normalizeIsrc(String? value) => isrc.normalizeIsrc(value);
static String normalizeSpotifyId(String? value) {
return (value ?? '').trim().toLowerCase();
@@ -240,8 +240,6 @@ class LocalLibrarySource {
enum LocalLibrarySortMode { album, title, artist, latest, quality }
enum LocalLibraryFilterMode { all, albums, singles }
class LocalLibraryLookupIndex {
final Set<String> isrcs;
final Set<String> matchKeys;