분류, 패키지 및 저장소 검색

패키지 상세v2.0.3

image_gallery_saver

이미지를 갤러리에 저장하기 위한 플러터 플러그인입니다. iOS는 Info.plist 파일에 다음 키를 추가해야 합니다.

AndroidiOS
30일 다운로드
1.9만
좋아요
885
Pub 점수
150

패키지 설치

flutter pub add image_gallery_saver

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

image_gallery_saver 패키지는 Android 및 iOS 양쪽에서 디바이스의 갤러리에 이미지를 저장할 수 있는 Flutter 플러그인입니다. 이는 시스템의 사진 라이브러리에 바이트 데이터 또는 파일 경로를 이미지로 저장하기 위한 간단한 API를 제공합니다. iOS에서는 사용자가 액세스 권한을 부여하기 위해 Info.plist 파일에 특정 키를 추가해야 합니다. 이 플러그인은 이미지를 생성하거나 다운로드하는 앱에서 '갤러리에 저장' 기능을 제공해야 하는 경우에 적합합니다. 로컬 파일과 원시 이미지 데이터 모두를 지원하여 다양한 용도에 유연하게 대응할 수 있습니다.

사용 사례

  • 캡처된 스크린샷 저장
  • 생성된 예술 작품 저장
  • 사용자가 만든 이미지 내보내기
  • 앱 콘텐츠에서 이미지 공유하기
  • 다운로드한 미디어 저장

주요 기능

  • 간단한 저장 API
  • Android 및 iOS를 지원합니다
  • 바이트 데이터와 파일 경로를 처리합니다
  • iOS에서 Info.plist 구성이 필요합니다
  • 크로스 플랫폼 호환성

적합한 대상

  • 이미지 편집 앱
  • 소셜 미디어 공유 도구
  • 사진 생성 유틸리티
  • 사용자 생성 콘텐츠를 포함한 앱
  • 오프라인 이미지 저장이 필요한 도구

고려 사항

  • iOS는 Info.plist 항목이 필요합니다
  • 권한은 플랫폼에 따라 달라질 수 있습니다
  • 큰 파일은 성능에 영향을 줄 수 있습니다
  • 제한된 사용자 정의 옵션
  • 내장된 진행 상황 피드백 없음

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

image_gallery_saver

Build Status pub package license

We use the image_picker plugin to select images from the Android and iOS image library, but it can't save images to the gallery. This plugin can provide this feature.

Usage

To use this plugin, add image_gallery_saver as a dependency in your pubspec.yaml file. For example:

dependencies:
  image_gallery_saver: '^2.0.3'

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. In Android version 10, Open the manifest file and add this line to your application tag

<application android:requestLegacyExternalStorage="true" .....>

Example

Saving an image from the internet, quality and name is option

  _saveLocalImage() async {
    RenderRepaintBoundary boundary =
        _globalKey.currentContext!.findRenderObject() as RenderRepaintBoundary;
    ui.Image image = await boundary.toImage();
    ByteData? byteData =
        await (image.toByteData(format: ui.ImageByteFormat.png));
    if (byteData != null) {
      final result =
          await ImageGallerySaver.saveImage(byteData.buffer.asUint8List());
      print(result);
    }
  }
  
  _saveNetworkImage() async {
    var response = await Dio().get(
        "https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=a62e824376d98d1069d40a31113eb807/838ba61ea8d3fd1fc9c7b6853a4e251f94ca5f46.jpg",
        options: Options(responseType: ResponseType.bytes));
    final result = await ImageGallerySaver.saveImage(
        Uint8List.fromList(response.data),
        quality: 60,
        name: "hello");
    print(result);
  }

Saving file(ig: video/gif/others) from the internet

  _saveNetworkGifFile() async {
    var appDocDir = await getTemporaryDirectory();
    String savePath = appDocDir.path + "/temp.gif";
    String fileUrl =
        "https://hyjdoc.oss-cn-beijing.aliyuncs.com/hyj-doc-flutter-demo-run.gif";
    await Dio().download(fileUrl, savePath);
    final result =
        await ImageGallerySaver.saveFile(savePath, isReturnPathOfIOS: true);
    print(result);
  }

  _saveNetworkVideoFile() async {
    var appDocDir = await getTemporaryDirectory();
    String savePath = appDocDir.path + "/temp.mp4";
    String fileUrl =
        "https://s3.cn-north-1.amazonaws.com.cn/mtab.kezaihui.com/video/ForBiggerBlazes.mp4";
    await Dio().download(fileUrl, savePath, onReceiveProgress: (count, total) {
      print((count / total * 100).toStringAsFixed(0) + "%");
    });
    final result = await ImageGallerySaver.saveFile(savePath);
    print(result);
  }

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트