mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-08-04 01:58:36 +02:00
refactor(dart): consolidate duplicated lookup, filename, and search-provider helpers
This commit is contained in:
@@ -398,18 +398,7 @@ class _AudioAnalysisCardState extends State<AudioAnalysisCard> {
|
||||
widget.filePath,
|
||||
channel: _spectrogramChannel,
|
||||
);
|
||||
if (image == null) {
|
||||
final artifact = await _generateSpectrogramForFile(
|
||||
widget.filePath,
|
||||
channel: _spectrogramChannel,
|
||||
);
|
||||
image = artifact.image;
|
||||
await _saveSpectrogramToCache(
|
||||
widget.filePath,
|
||||
image,
|
||||
channel: _spectrogramChannel,
|
||||
);
|
||||
}
|
||||
image ??= await _generateAndCacheSpectrogram();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_spectrogramImage?.dispose();
|
||||
@@ -426,6 +415,19 @@ class _AudioAnalysisCardState extends State<AudioAnalysisCard> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<ui.Image> _generateAndCacheSpectrogram() async {
|
||||
final artifact = await _generateSpectrogramForFile(
|
||||
widget.filePath,
|
||||
channel: _spectrogramChannel,
|
||||
);
|
||||
await _saveSpectrogramToCache(
|
||||
widget.filePath,
|
||||
artifact.image,
|
||||
channel: _spectrogramChannel,
|
||||
);
|
||||
return artifact.image;
|
||||
}
|
||||
|
||||
Future<void> _analyze({bool forceRefresh = false}) async {
|
||||
if (_analyzing) return;
|
||||
setState(() {
|
||||
@@ -470,18 +472,7 @@ class _AudioAnalysisCardState extends State<AudioAnalysisCard> {
|
||||
);
|
||||
}
|
||||
|
||||
if (image == null) {
|
||||
final artifact = await _generateSpectrogramForFile(
|
||||
widget.filePath,
|
||||
channel: _spectrogramChannel,
|
||||
);
|
||||
image = artifact.image;
|
||||
await _saveSpectrogramToCache(
|
||||
widget.filePath,
|
||||
image,
|
||||
channel: _spectrogramChannel,
|
||||
);
|
||||
}
|
||||
image ??= await _generateAndCacheSpectrogram();
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
|
||||
Reference in New Issue
Block a user