Change image saver to write to galleries not files on mobile

codemagic-setup
Hank Grabowski 2023-11-18 20:53:29 -05:00
rodzic 91d6f944b0
commit 160fda0f72
5 zmienionych plików z 53 dodań i 34 usunięć

Wyświetl plik

@ -4,7 +4,8 @@
<application
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher_round"
android:label="Relatica">
android:label="Relatica"
android:requestLegacyExternalStorage="true">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
@ -19,35 +20,37 @@
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"/>
android:resource="@style/NormalTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.linusu.flutter_web_auth_2.CallbackActivity"
android:exported="true">
<intent-filter android:label="flutter_web_auth_2">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="relatica"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="relatica" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2"/>
android:value="2" />
</application>
<queries>
<intent>
<action android:name="android.intent.action.VIEW"/>
<data android:scheme="https"/>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
</queries>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>

Wyświetl plik

@ -45,6 +45,8 @@ PODS:
- FMDB (2.7.5):
- FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5)
- image_gallery_saver (2.0.2):
- Flutter
- image_picker_ios (0.0.1):
- Flutter
- media_kit_libs_ios_video (1.0.4):
@ -90,6 +92,7 @@ DEPENDENCIES:
- flutter_file_dialog (from `.symlinks/plugins/flutter_file_dialog/ios`)
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
- flutter_web_auth_2 (from `.symlinks/plugins/flutter_web_auth_2/ios`)
- image_gallery_saver (from `.symlinks/plugins/image_gallery_saver/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- media_kit_libs_ios_video (from `.symlinks/plugins/media_kit_libs_ios_video/ios`)
- media_kit_native_event_loop (from `.symlinks/plugins/media_kit_native_event_loop/ios`)
@ -127,6 +130,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_secure_storage/ios"
flutter_web_auth_2:
:path: ".symlinks/plugins/flutter_web_auth_2/ios"
image_gallery_saver:
:path: ".symlinks/plugins/image_gallery_saver/ios"
image_picker_ios:
:path: ".symlinks/plugins/image_picker_ios/ios"
media_kit_libs_ios_video:
@ -166,6 +171,7 @@ SPEC CHECKSUMS:
flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be
flutter_web_auth_2: 051cf9f5dc366f31b5dcc4e2952c2b954767be8a
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb
image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
media_kit_libs_ios_video: a5fe24bc7875ccd6378a0978c13185e1344651c1
media_kit_native_event_loop: e6b2ab20cf0746eb1c33be961fcf79667304fa2a
@ -186,4 +192,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 1df1bb3ed89ef4be6115286519e24a9fad12e640
COCOAPODS: 1.10.2
COCOAPODS: 1.14.2

Wyświetl plik

@ -2,7 +2,7 @@ import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter_file_dialog/flutter_file_dialog.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:path/path.dart' as p;
import 'package:path_provider/path_provider.dart';
@ -74,11 +74,12 @@ class _MediaViewerScreenState extends State<MediaViewerScreen> {
}
if (Platform.isAndroid || Platform.isIOS) {
final params = SaveFileDialogParams(
data: bytesResult.value,
fileName: filename,
);
await FlutterFileDialog.saveFile(params: params);
final saveResult = await ImageGallerySaver.saveImage(bytesResult.value);
if (saveResult['isSuccess']) {
buildSnackbar(context, 'Image saved to gallery');
} else {
buildSnackbar(context, 'Unable to save to gallery, check permissions');
}
} else {
final location = await FilePicker.platform.saveFile(
dialogTitle: 'Save Image',

Wyświetl plik

@ -629,6 +629,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.1.3"
image_gallery_saver:
dependency: "direct main"
description:
name: image_gallery_saver
sha256: "0aba74216a4d9b0561510cb968015d56b701ba1bd94aace26aacdd8ae5761816"
url: "https://pub.dev"
source: hosted
version: "2.0.3"
image_picker:
dependency: "direct main"
description:

Wyświetl plik

@ -54,6 +54,7 @@ dependencies:
uuid: ^4.1.0
video_player: ^2.4.10
flutter_svg: ^2.0.5
image_gallery_saver: ^2.0.3
dev_dependencies: