カテゴリー・パッケージ・リポジトリを検索

パッケージ詳細v2.3.2

gallery_saver

ネットワークまたは一時ファイルからの画像および動画を外部ストレージに保存します。画像と動画は、AndroidギャラリーおよびiOSフォトで表示されます。

AndroidiOS
30日間ダウンロード
3720
いいね数
489
Pub ポイント
130

パッケージをインストール

flutter pub add gallery_saver

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Gallery Saver は、ネットワーク URL や一時ファイルから画像や動画をデバイスの外部ストレージに保存できる Flutter パッケージです。保存されたメディアは、Android ではネイティブギャラリー、iOS では Photos アプリで表示されます。システムレベルのフォトライブラリと互換性を持ちながら、マルチメディアコンテンツをローカルに永続化するプロセスを簡素化します。共有またはダウンロードしたコンテンツをユーザーがデバイスのメディアコレクションに直接保存できるアプリに最適です。

用途

  • URLからダウンロードした画像を保存する
  • ユーザーが生成したメディアの保存
  • デバイスのギャラリーにコンテンツを共有する
  • 画像/動画ビューアとの統合
  • メディアのオフラインアクセスを有効にする
  • ソーシャルメディア共有のサポート

主な機能

  • 画像と動画の両方を保存します
  • Android および iOS で動作します
  • ネイティブギャラリー/写真に表示されます
  • ネットワークおよび一時ファイルソースをサポート
  • メディアを保存するためのシンプルな API
  • メディアメタデータを維持する

適している対象

  • メディア共有アプリ
  • 写真ビューアアプリケーション
  • コンテンツダウンローダー
  • ソーシャルメディア統合
  • オフラインメディアアクセスを必要とするアプリ
  • ユーザー生成コンテンツプラットフォーム

注意事項

  • Androidで適切な権限が必要です
  • 実行時権限のリクエストが必要になる場合があります
  • ファイルサイズの制限はデバイスのストレージに依存します
  • iOS は Info.plist に適切なプライバシー説明を必要とします
  • 大規模なメディア処理には適していません
  • アルバムの整理に関する制御が限られている

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Gallery Saver for Flutter

Saves images and videos from network or temporary file to external storage. Both images and videos will be visible in Android Gallery and iOS Photos.

NOTE: If you want to save network image or video link, it has to contain 'http/https' prefix.

Installation

First, add gallery_saver as a dependency in your pubspec.yaml file.

iOS

Add the following keys to your Info.plist file, located in <project root>/ios/Runner/Info.plist:

  • NSPhotoLibraryUsageDescription - describe why your app needs permission for the photo library. This is called Privacy - Photo Library Usage Description in the visual editor.
Android
  • android.permission.WRITE_EXTERNAL_STORAGE - Permission for usage of external storage
Example
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:gallery_saver/gallery_saver.dart';
import 'package:image_picker/image_picker.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String firstButtonText = 'Take photo';
  String secondButtonText = 'Record video';
  double textSize = 20;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
      body: Container(
        color: Colors.white,
        child: Column(
          children: <Widget>[
            Flexible(
              flex: 1,
              child: Container(
                child: SizedBox.expand(
                  child: RaisedButton(
                    color: Colors.blue,
                    onPressed: _takePhoto,
                    child: Text(firstButtonText,
                        style:
                            TextStyle(fontSize: textSize, color: Colors.white)),
                  ),
                ),
              ),
            ),
            Flexible(
              child: Container(
                  child: SizedBox.expand(
                child: RaisedButton(
                  color: Colors.white,
                  onPressed: _recordVideo,
                  child: Text(secondButtonText,
                      style: TextStyle(
                          fontSize: textSize, color: Colors.blueGrey)),
                ),
              )),
              flex: 1,
            )
          ],
        ),
      ),
    ));
  }

  void _takePhoto() async {
    ImagePicker.pickImage(source: ImageSource.camera)
        .then((File recordedImage) {
      if (recordedImage != null && recordedImage.path != null) {
        setState(() {
          firstButtonText = 'saving in progress...';
        });
        GallerySaver.saveImage(recordedImage.path).then((String path) {
          setState(() {
            firstButtonText = 'image saved!';
          });
        });
      }
    });
  }

  void _recordVideo() async {
    ImagePicker.pickVideo(source: ImageSource.camera)
        .then((File recordedVideo) {
      if (recordedVideo != null && recordedVideo.path != null) {
        setState(() {
          secondButtonText = 'saving in progress...';
        });
        GallerySaver.saveVideo(recordedVideo.path).then((String path) {
          setState(() {
            secondButtonText = 'video saved!';
          });
        });
      }
    });
  }
  void _saveNetworkVideo() async {
    String path =
        'https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4';
    GallerySaver.saveVideo(path).then((bool success) {
      setState(() {
        print('Video is saved');
      });
    });
  }

  void _saveNetworkImage() async {
    String path =
        'https://image.shutterstock.com/image-photo/montreal-canada-july-11-2019-600w-1450023539.jpg';
    GallerySaver.saveImage(path).then((bool success) {
      setState(() {
        print('Image is saved');
      });
    });
  }
}

カテゴリー

依存関係

依存関係一覧 3 件

ソースリポジトリ

このパッケージを使用しているプロジェクト