# fluttertpc_gallery_saver **Repository Path**: openharmony-sig/fluttertpc_gallery_saver ## Basic Information - **Project Name**: fluttertpc_gallery_saver - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 7 - **Created**: 2024-05-21 - **Last Updated**: 2025-05-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 🚨 **重要提示 | IMPORTANT** > > **⚠️ 此代码仓已归档。新地址请访问 [fluttertpc_gallery_saver](https://gitcode.com/openharmony-sig/fluttertpc_gallery_saver)。| ⚠️ This repository has been archived. For the new address, please visit [fluttertpc_gallery_saver](https://gitcode.com/openharmony-sig/fluttertpc_gallery_saver).** > --- > # 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](https://flutter.io/platform-plugins/). ### iOS Add the following keys to your _Info.plist_ file, located in `/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 ### Ohos Permissions: * `ohos.permission.INTERNET` * `ohos.permission.READ_MEDIA` * `ohos.permission.WRITE_IMAGEVIDEO` - ACL ### Example ``` dart 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 { 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: [ 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'); }); }); } } ```