How to Share a File Using Flutter ?

· 2 min read
How to Share a File Using Flutter
How to Share a File Using Flutter

Sharing data or images on a social media platform has become very popular now a days from a mobile application so in this article we will learn about How to share a File using flutter?

How to Share a File Using Flutter?

You can use the EsysFlutterShare Plugin. In version 1.0.0 you can share any file you like and its working on both, iOS and Android.

Just put that in your pubspec.yaml:

  esys_flutter_share: ^1.0.0

Import the lib:

import 'package:esys_flutter_share/esys_flutter_share.dart';

Share a file:

final ByteData bytes = await rootBundle.load('assets/image1.png');
await Share.file('esys image', 'esys.png', bytes.buffer.asUint8List(), 'image/png');

User can also make it happen by a plugin like share_extend

void share() async {
Directory dir = await getApplicationDocumentsDirectory();
File testFile = new File("${dir.path}/sound.m4a");
if (!await testFile.exists()) {
  await testFile.create(recursive: true);
  testFile.writeAsStringSync("test for share documents file");
ShareExtend.share(testFile.path, "file");

There is also one more share plugin available for the same.

Share.shareFiles(['${directory.path}/image.jpg'], text: 'Great picture');
Share.shareFiles(['${directory.path}/image1.jpg', '${directory.path}/image2.jpg']);


Thanks for being with us on a Flutter Journey !!!

Keep Learning !!! Keep Fluttering !!!

Still, Need a Support for Flutter Development? We would love to assist you.

In this article, We have been through How to Share a File using Flutter? is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs and etc. is one of the most popular online portal dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge on Flutter.

Leave a Reply