Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/huhx/flutter_gallery_saver
https://github.com/huhx/flutter_gallery_saver
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/huhx/flutter_gallery_saver
- Owner: huhx
- License: mit
- Created: 2023-02-05T02:28:00.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-12T14:24:05.000Z (almost 2 years ago)
- Last Synced: 2023-08-09T13:59:48.826Z (over 1 year ago)
- Language: Swift
- Size: 136 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# awesome_gallery_saver
Save images or videos to the gallery.
## Usage
To use this plugin, add `awesome_gallery_saver` as a dependency in your pubspec.yaml file. For example:
```yaml
dependencies:
awesome_gallery_saver: ^0.0.6
```## iOS
Your project need create with swift.
Add the following keys to your Info.plist file, located in /ios/Runner/Info.plist:
* NSPhotoLibraryAddUsageDescription - describe why your app needs permission for the photo library. This is called Privacy - Photo Library Additions Usage Description in the visual editor
## Android
You need to ask for storage permission to save an image to the gallery. You can handle the storage permission using [flutter_permission_handler](https://github.com/BaseflowIT/flutter-permission-handler).
In Android version 10, Open the manifest file and add this line to your application tag
```
```## Example
Saving an image from the internet, quality and name is option
``` dart
Future _saveImage() async {
final Response response = await Dio().get(
"https://lmg.jj20.com/up/allimg/1114/040221103339/210402103339-8-1200.jpg",
options: Options(responseType: ResponseType.bytes),
);
final result = await GallerySaver.saveImage(
Uint8List.fromList(response.data),
quality: 60,
name: "hello",
);
print(result);
}
```Saving file(ig: images/video/gif/others) from the internet
``` dart
Future _saveFile() async {
final appDocDir = await getTemporaryDirectory();
String savePath = appDocDir.path + "/image.jpg";
await Dio().download("https://lmg.jj20.com/up/allimg/1114/040221103339/210402103339-8-1200.jpg", savePath);
final result = await GallerySaver.saveFile(savePath);
print(result);
}
```