안드로이드 및 iOS 기기에서 네이티브 갤러리에 이미지를 저장할 수 있는 플러터 플러그인입니다. 기본 앨범 또는 사용자가 지정한 이름의 커스텀 앨범에 저장하는 것을 지원하며, 장치별 사진 저장 시스템과 원활하게 통합됩니다. 이미지 생성 또는 수정 앱의 미디어 지속성을 단순화하고 최소한의 설정으로 크로스플랫폼 호환성을 제공합니다. 사용자 친화적인 이미지 내보내기 기능을 필요로 하는 앱에 적합합니다.
사용 사례
앱에서 생성된 이미지를 저장하는 방법
사용자의 갤러리로 편집된 사진 내보내기
정리된 이미지 저장을 위한 사용자 정의 앨범 만들기
사용자와 앱에서 생성한 시각적 콘텐츠 공유
내장 갤러리에서 이미지 백업 자동화
주요 기능
크로스 플랫폼 지원 (Android 및 iOS)
기본 또는 이름 지정된 앨범에 저장
이미지 저장을 위한 간단한 API
네이티브 갤러리 통합
필수 최소 구성
적합한 대상
이미지 편집 앱
사진 공유 애플리케이션
시각 콘텐츠를 생성하는 앱
사용자 중심 미디어 도구
갤러리 접근이 필요한 개발자
고려 사항
두 플랫폼 모두에서 적절한 권한이 필요합니다
이미지 파일로 제한
비디오 또는 기타 미디어 유형에 대한 지원 없음
플랫폼별 동작은 다를 수 있습니다
권한 요청 수동 처리 필요
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
save_in_gallery
Flutter plugin that allows you to save images in native gallery in both Android and iOS. You can either save them in default album or in named album of your choice.
Installation
For installation details see Installing tab on this page.
Configuration
iOS
To use this plugin in iOS you must add 2 new records to configuration file info.plist located in ios/Runner directory. To do so, open iOS project in Xcode by running
open ios/Runner.xcworkspace
then right-click on info.plist file in project navigator and click open as > source code. Then add following 2 records at the end of <dict> object:
<key>NSPhotoLibraryAddUsageDescription</key><string>write</string>
Where write should be reason why your app requires write access to user's gallery. This is necessary to save images in gallery.
<key>NSPhotoLibraryUsageDescription</key><string>read</string>
Where read should be reason why your app requires read access to user's gallery. This is necessary to create and use named albums in gallery.
Be aware that app will ask user's permission to read/write gallery access using standard iOS alerts when you will use methods provided by this plugin. These alerts' appearance can not be changed.
If user declines access, these alerts can not be shown again, instead you must use custom controls to redirect user to Settings app, so they can grant access rights themselves. Methods provided by this plugin will not work unless user provides proper access rights.
Android
This plugin should work out-of-the-box and does not require additional configuration.
Be aware that app will ask user's permission to WRITE_EXTERNAL_STORAGE using standard Android alerts when you will use methods provided by this plugin. These alerts' appearance can not be changed.
If user declines access, these alerts can not be shown again, instead you must use custom controls to redirect user to Settings app, so they can grant access rights themselves. Methods provided by this plugin will not work unless user provides proper access rights.
Examples
Save multiple images from app's assets to default gallery
import'package:save_in_gallery/save_in_gallery.dart';
final _imageSaver = ImageSaver();
Future<void> saveAssetImage() async {
// 1final urls = [
"assets/image1.jpg",
"assets/image2.jpg",
"assets/image3.jpg",
];
// 2 List<Uint8List> bytesList = [];
for (final url in urls) {
final bytes = await rootBundle.load(url);
bytesList.add(bytes.buffer.asUint8List());
}
// 3final res = await _imageSaver.saveImages(
imageBytes: bytesList
);
// 4
}
Prepare list of asset URLs;
Load each image, extract byte data, and map to Uint8List type;
Invoke plugin method to save loaded images;
res variable will hold result of saving operation. If it's true, then everything went as expected and images have been successfully saved. Otherwise something went wrong along the way. Use this variable to provide feedback to user.
Fetch image from web and save it to a named album in gallery
Create NetworkImage object with your URL and load it's configuration;
Extract byte data from image;
Invoke plugin method to save fetched image in custom album named dir_name;
res variable will hold result of saving operation. If it's true, then everything went as expected and image have been successfully saved. Otherwise something went wrong along the way. Use this variable to provide feedback to user.