From 8ddc69603d721f5d9633b0c6d0d2ee437a805009 Mon Sep 17 00:00:00 2001 From: misakajimmy Date: Wed, 22 Feb 2023 19:54:00 +0800 Subject: [PATCH] DEV UPDATE:Maybe fixed ios gif save --- lib/routes/picture/pictureDetail.dart | 8 ++++++-- macos/Flutter/GeneratedPluginRegistrant.swift | 2 ++ pubspec.lock | 8 ++++++++ pubspec.yaml | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/routes/picture/pictureDetail.dart b/lib/routes/picture/pictureDetail.dart index b4cc039..459dbc2 100644 --- a/lib/routes/picture/pictureDetail.dart +++ b/lib/routes/picture/pictureDetail.dart @@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; import 'package:path_provider/path_provider.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:image_gallery_saver/image_gallery_saver.dart'; +import 'package:photo_manager/photo_manager.dart'; class PictureDetail extends StatefulWidget { const PictureDetail({ @@ -38,8 +39,11 @@ class _PictureDetailState extends State { var appDocDir = await getTemporaryDirectory(); String savePath = appDocDir.path + "/tmp.gif"; await Dio().download(url, savePath); - final result = await ImageGallerySaver.saveFile(savePath); - print(result); + final result = await PhotoManager.requestPermissionExtend(); + if (result.isAuth) { + final asset = await PhotoManager.editor + .saveImageWithPath(savePath, title: url.split("/").last); + } } else { var response = await Dio() .get(url, options: Options(responseType: ResponseType.bytes)); diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 3b68459..025750c 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,6 +7,7 @@ import Foundation import package_info_plus import path_provider_foundation +import photo_manager import sentry_flutter import shared_preferences_foundation import sqflite @@ -15,6 +16,7 @@ import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + PhotoManagerPlugin.register(with: registry.registrar(forPlugin: "PhotoManagerPlugin")) SentryFlutterPlugin.register(with: registry.registrar(forPlugin: "SentryFlutterPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) diff --git a/pubspec.lock b/pubspec.lock index 9134754..b37b89d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -656,6 +656,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "5.1.0" + photo_manager: + dependency: "direct main" + description: + name: photo_manager + sha256: "55d50ad1b8f984c57fa7c4bd4980f4760e80d3d9355263cf72624a6ff1bf2b5b" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.5.2" platform: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 99b4dc3..bd456a6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -55,6 +55,7 @@ dependencies: modal_bottom_sheet: ^2.1.2 path_provider: ^2.0.12 sentry_flutter: ^6.20.1 + photo_manager: ^2.5.2 dev_dependencies: flutter_test: