# fluttertpc_share_extend **Repository Path**: openharmony-sig/fluttertpc_share_extend ## Basic Information - **Project Name**: fluttertpc_share_extend - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 5 - **Created**: 2024-05-21 - **Last Updated**: 2025-05-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 🚨 **重要提示 | IMPORTANT** > > **⚠️ 此代码仓已归档。新地址请访问 [fluttertpc_share_extend](https://gitcode.com/openharmony-sig/fluttertpc_share_extend)。| ⚠️ This repository has been archived. For the new address, please visit [fluttertpc_share_extend](https://gitcode.com/openharmony-sig/fluttertpc_share_extend).** > --- > Language: [English](https://github.com/zhouteng0217/ShareExtend/blob/master/README.md) | [中文简体](https://github.com/zhouteng0217/ShareExtend/blob/master/README-cn.md) # ShareExtend [![pub package](https://img.shields.io/pub/v/share_extend.svg)](https://pub.dartlang.org/packages/share_extend) A Flutter plugin for iOS and Android for sharing text, image, video and file with system ui. ## Installation First, add `share_extend` as a dependency in your pubspec.yaml file. ``` dependencies: share_extend: "^2.0.0" ``` ### iOS Add the following key to your info.plist file, located in `/ios/Runner/Info.plist` for saving shared images to photo library. ``` NSPhotoLibraryAddUsageDescription describe why your app needs access to write photo library ``` ### Android If your project needs read and write permissions for sharing external storage file, please add the following permissions to your AndroidManifest.xml, located in `/android/app/src/main/AndroidManifest.xml` ``` ``` ## Import ``` import 'package:share_extend/share_extend.dart'; ``` ## Example ``` //share text ShareExtend.share("share text", "text","android share panel title","share subject"); //share image File f = await ImagePicker.pickImage(source: ImageSource.gallery); ShareExtend.share(f.path, "image"); //share video File f = await ImagePicker.pickVideo( source: ImageSource.gallery); ShareExtend.share(f.path, "video"); //share file Directory dir = Platform.isAndroid ? await getExternalStorageDirectory() : await getApplicationDocumentsDirectory(); File testFile = new File("${dir.path}/flutter/test.txt"); if (!await testFile.exists()) { await testFile.create(recursive: true); testFile.writeAsStringSync("test for share documents file"); } ShareExtend.share(testFile.path, "file"); ///share multiple images _shareMultipleImages() async { List assetList = await MultiImagePicker.pickImages(maxImages: 5); var imageList = List(); for (var asset in assetList) { String path = await _writeByteToImageFile(await asset.getByteData(quality: 30)); imageList.add(path); } ShareExtend.shareMultiple(imageList, "image",subject: "share muti image"); } Future _writeByteToImageFile(ByteData byteData) async { Directory dir = Platform.isAndroid ? await getExternalStorageDirectory() : await getApplicationDocumentsDirectory(); File imageFile = new File( "${dir.path}/flutter/${DateTime.now().millisecondsSinceEpoch}.png"); imageFile.createSync(recursive: true); imageFile.writeAsBytesSync(byteData.buffer.asUint8List(0)); return imageFile.path; } ```