mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-31 00:07:25 +02:00
perf: reduce UI jank via memoization, compute isolates, SQL-backed playlist picker, and viewport-aware image caching
- Move explore JSON decode/encode to compute() isolate to avoid blocking main thread - Memoize search sort results (artists/albums/playlists/tracks) in HomeTab; invalidate on new query - Extract _DownloadedOrRemoteCover StatefulWidget with proper embedded-cover lifecycle management - Replace O(playlists x tracks) in-memory playlist picker check with SQL loadPlaylistPickerSummaries query - Add FutureProvider.family (libraryPlaylistPickerSummariesProvider) invalidated on all playlist mutations - Memoize _buildQueueHistoryStats, localPathMatchKeys, and localSingleItems in QueueTab - Add coverCacheWidthForViewport util; apply memCacheWidth/cacheWidth based on real DPR across all album/playlist/track screens - Convert sync file ops in TrackMetadataScreen to async; use mtime+size as validation token - Fetch Deezer album nb_tracks in parallel via fetchAlbumTrackCounts
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
int coverCacheWidthForViewport(
|
||||
BuildContext context, {
|
||||
double widthMultiplier = 1.0,
|
||||
int min = 320,
|
||||
int max = 2048,
|
||||
}) {
|
||||
final dpr = MediaQuery.devicePixelRatioOf(context);
|
||||
final logicalWidth = MediaQuery.sizeOf(context).width * widthMultiplier;
|
||||
return (logicalWidth * dpr).round().clamp(min, max);
|
||||
}
|
||||
Reference in New Issue
Block a user