This commit is contained in:
bluesea 2024-05-15 16:19:37 +08:00
parent badd6b9f13
commit d410ecb396
3 changed files with 29 additions and 3 deletions

View File

@ -21,7 +21,9 @@ class DownloadPageController extends GetxController {
Future < void> saveImgToAlbum(String imgUrl) async { Future < void> saveImgToAlbum(String imgUrl) async {
await DownloadManager.saveNetworkImage(imgUrl);
//
// await DownloadManager.saveNetworkImage(imgUrl);
//android, //android,
// if (Platform.isAndroid) { // if (Platform.isAndroid) {
@ -34,7 +36,8 @@ class DownloadPageController extends GetxController {
} }
Future <void> setWallpaper(String imgUrl) async { Future <void> setWallpaper(String imgUrl) async {
await DownloadManager.setWallpaper(imgUrl); //
await DownloadManager.setWallpaperNative(imgUrl);
} }

View File

@ -36,7 +36,7 @@ class DownloadPageView extends GetView<DownloadPageController> {
} }
Stack getBodyItem(String fileName) { Stack getBodyItem(String fileName) {
var imgUrl = controller.localDir.value +'/'+ fileName; var imgUrl = '${controller.localDir.value}/$fileName';
return Stack(// return Stack(//
children: [ children: [
Image.file( Image.file(

View File

@ -78,11 +78,34 @@ class DownloadManager {
// toastDetails: ToastDetails.success(), // toastDetails: ToastDetails.success(),
// errorToastDetails: ToastDetails.error(), // errorToastDetails: ToastDetails.error(),
); );
print("result:$result ");
} on PlatformException { } on PlatformException {
result = false; result = false;
print("err ....result:$result ");
}
return result;
}
static Future<bool> setWallpaperNative(String urlStr) async {
bool result;
try {
result = await AsyncWallpaper.setWallpaperFromFile(
filePath: urlStr,
wallpaperLocation: AsyncWallpaper.HOME_SCREEN,
goToHome: false,
// toastDetails: ToastDetails.success(),
// errorToastDetails: ToastDetails.error(),
);
print("result:$result ");
} on PlatformException {
result = false;
print("err ....result:$result ");
} }
return result; return result;
} }
} }