Skip to content

Commit

Permalink
fix: Changing gallery_saver to gal. visual-space#234
Browse files Browse the repository at this point in the history
This was made because `gallery_saver` was "stuck" with a dependency of `http` at 0.13, not allowing to upgrade other dependencies. Check CarnegieTechnologies/gallery_saver#205 for more information.

This commit adds `gal`, which does the same thing. `dio` and `path` were needed to recreate the behaviour of `gallery_saver`. `gal`, however, is updated and uses the latest versions of packages.
  • Loading branch information
LuchoTurtle committed Sep 6, 2023
1 parent 4f3f1e3 commit 0c6671f
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 21 deletions.
11 changes: 9 additions & 2 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
package="com.example.app">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application

<!-- gal: For supporting API <= 29 :gal-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29" />
<!-- gal: For supporting API <= 29 :gal-->

<application
android:name="${applicationName}"
android:label="app"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/ic_launcher"
android:requestLegacyExternalStorage="true"> <!-- gal: For saving to album in API 29 :gal-->
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
13 changes: 11 additions & 2 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,17 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Need to save image</string>

<!-- gal: Required -->
<key>NSPhotoLibraryAddUsageDescription</key>
<string>We need add only access to save medias</string>
<!-- gal: Required -->

<!-- gal: Required for ios < 14 or saving to album -->
<key>NSPhotoLibraryUsageDescription</key>
<string>We need access to save medias</string>
<!-- gal: Required for ios < 14 or saving to album -->

<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
15 changes: 12 additions & 3 deletions lib/embeds/widgets/option-menu-for-readonly-image.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import 'dart:io';

import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:gallery_saver/gallery_saver.dart';
import 'package:gal/gal.dart';
import 'package:path/path.dart';

import '../../shared/state/editor.state.dart';
import '../../shared/translations/toolbar.i18n.dart';
Expand Down Expand Up @@ -54,11 +58,15 @@ class OptionMenuForReadOnlyImage extends StatelessWidget {
icon: Icons.save,
color: Colors.greenAccent,
text: 'Save'.i18n,
onPressed: () {
onPressed: () async {
final _imageUrl = _mediaLoaderService.appendFileExtensionToImageUrl(
imageUrl,
);
GallerySaver.saveImage(_imageUrl).then(

// Download image to gallery
final imagePath = '${Directory.systemTemp.path}/${basename(_imageUrl)}';
await Dio().download(_imageUrl, imagePath);
await Gal.putImage(imagePath).then(
(_) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
Expand All @@ -68,6 +76,7 @@ class OptionMenuForReadOnlyImage extends StatelessWidget {
Navigator.pop(context);
},
);
;
},
);

Expand Down
32 changes: 20 additions & 12 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.4.1"
dio:
dependency: "direct main"
description:
name: dio
sha256: ce75a1b40947fea0a0e16ce73337122a86762e38b982e1ccb909daa3b9bc4197
url: "https://pub.dev"
source: hosted
version: "5.3.2"
equatable:
dependency: transitive
description:
Expand Down Expand Up @@ -272,14 +280,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
gallery_saver:
gal:
dependency: "direct main"
description:
name: gallery_saver
sha256: df8b7e207ca12d64c71e0710a7ee3bc48aa7206d51cc720716fedb1543a66712
name: gal
sha256: "1bdef5879e4569910cfd8c77f460f98fcb7a1f910026af1daa80869856c67d66"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
version: "1.9.1"
gettext_parser:
dependency: transitive
description:
Expand All @@ -300,10 +308,10 @@ packages:
dependency: "direct main"
description:
name: google_fonts
sha256: "8f099045e2f2a30e4d4d0a35f40c6bc941a8f2ca0e10ad9d214ee9edd3f37483"
sha256: e20ff62b158b96f392bfc8afe29dee1503c94fbea2cbe8186fd59b756b8ae982
url: "https://pub.dev"
source: hosted
version: "3.0.1"
version: "5.1.0"
html:
dependency: transitive
description:
Expand All @@ -316,10 +324,10 @@ packages:
dependency: transitive
description:
name: http
sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482"
sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525"
url: "https://pub.dev"
source: hosted
version: "0.13.5"
version: "1.1.0"
http_parser:
dependency: transitive
description:
Expand Down Expand Up @@ -372,10 +380,10 @@ packages:
dependency: transitive
description:
name: image_picker_platform_interface
sha256: "7cef2f28f4f2fef99180f636c3d446b4ccbafd6ba0fad2adc9a80c4040f656b8"
sha256: ed9b00e63977c93b0d2d2b343685bed9c324534ba5abafbb3dfbd6a780b1b514
url: "https://pub.dev"
source: hosted
version: "2.6.2"
version: "2.9.1"
intl:
dependency: transitive
description:
Expand Down Expand Up @@ -425,7 +433,7 @@ packages:
source: hosted
version: "2.1.0"
path:
dependency: transitive
dependency: "direct main"
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
Expand Down Expand Up @@ -783,4 +791,4 @@ packages:
version: "8.1.1"
sdks:
dart: ">=3.1.0-185.0.dev <4.0.0"
flutter: ">=3.0.0"
flutter: ">=3.7.0"
6 changes: 4 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ dependencies:
youtube_player_flutter: ^8.0.0
diff_match_patch: ^0.4.1
i18n_extension: ^4.2.1
gallery_saver: ^2.3.2
device_info_plus: ^3.2.3
google_fonts: ^3.0.1
google_fonts: ^5.1.0
gal: ^1.9.1
dio: ^5.3.2
path: ^1.8.3

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 0c6671f

Please sign in to comment.