通知中心封面图显示

部分界面的信息更新
缓存系统初步引入
即将进入播放列表更新
This commit is contained in:
2026-08-25 23:09:17 +08:00
parent 0e8921742c
commit f2b4d1f46d
16 changed files with 454 additions and 161 deletions
+55
View File
@@ -0,0 +1,55 @@
// lib/utils/file_provider_utils.dart
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:flutter/foundation.dart';
class FileProviderUtils {
static const MethodChannel _channel =
MethodChannel('com.lxh.qingting_player/file_provider');
/// 生成 content:// URIAndroid only
static Future<Uri?> getContentUri(File file) async {
if (!Platform.isAndroid) {
// 非 Android 平台直接返回 file:// URI
return Uri.file(file.path);
}
try {
final uriString = await _channel.invokeMethod('getContentUri', {
'path': file.path,
});
if (uriString is String && uriString.isNotEmpty) {
return Uri.parse(uriString);
}
return Uri.file(file.path);
} on PlatformException catch (e) {
debugPrint('⚠️ [FileProviderUtils] PlatformException: ${e.message}');
return Uri.file(file.path);
} catch (e) {
debugPrint('⚠️ [FileProviderUtils] Error: $e');
return Uri.file(file.path);
}
}
/// 检查文件是否存在
static Future<bool> fileExists(String path) async {
try {
final file = File(path);
return await file.exists();
} catch (e) {
return false;
}
}
/// 删除文件
static Future<void> deleteFile(String path) async {
try {
final file = File(path);
if (await file.exists()) {
await file.delete();
}
} catch (e) {
// ignore
}
}
}