sams_flutter_share 0.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 65

sams_flutter_share #

Share files easily and quick

Getting Started #

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

0.0.2 #

A simple flutter file share. You can share any type of file and can share with a specific app. Please check example.


import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:sams_flutter_share/sams_flutter_share.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key key}) : super(key: key);

  //Launch share pop up and choose an app to share
  shareText() => SamsFlutterShare.shareText(
      'I am a Text, Share Me', //Text to share
      'text/*', //Mime type or type of data to share
      shareTitle: 'Share with' //Title of the share pop up modal

  //Directly share to Whatsapp
  shareTextToWhatsapp() => SamsFlutterShare.shareText(
        'I am a Text, Share Me', 'text/*',
            'com.whatsapp', //replace with  the package name of your desired app

  shareImage() async {
    final ByteData fileBytes = await rootBundle.load('images/bat1.jpg');
    await SamsFlutterShare.shareFile(
            .asUint8List(), //Reads file as byte list rootbundle returns bytedata
        'bat1.jpg', //File name
        'image/jpg', //Meme type
        captionText: 'Cool Share');

    //Share a file within the directory.
    // final fileBytes = File(filePath).readAsBytesSync();
    // await SamsFlutterShare.shareFile(fileBytes, basename(filePath), memeType,
    //   shareTitle: 'Share with',
    //  );

  shareMultipleImages() async {
    final file1 =
        (await rootBundle.load('images/bat1.jpg')).buffer.asUint8List();
    final file2 =
        (await rootBundle.load('images/bat2.jpg')).buffer.asUint8List();
    final file3 =
        (await rootBundle.load('images/bat3.jpg')).buffer.asUint8List();

    await SamsFlutterShare.shareMultipleFiles(
        'bat1.jpg': file1,
        'bat2.jpg': file2,
        'bat3.jpg': file3,
      'image/jpg', //if file are of different types replace with */*
      captionText: 'Multiple images',

  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
      appBar: AppBar(
        title: Text("Sam's Flutter Share Example"),
      body: Center(
        child: ListView(
          padding: EdgeInsets.symmetric(horizontal: 10),
          children: <Widget>[
            SizedBox(height: 50),
            Center(child: Text('I am a Text, Share Me')),
              child: RaisedButton.icon(
                icon: Icon(Icons.share),
                label: Text('Share the text Above'),
                onPressed: () => shareText(),
            Center(child: Text('I am a Text, Share Me to Whatsapp')),
              child: RaisedButton.icon(
                icon: Icon(Icons.share),
                label: Text('Share the text Above to Whatsapp'),
                onPressed: () => shareTextToWhatsapp(),
                child: Image.asset(
              height: 150,
              child: RaisedButton.icon(
                icon: Icon(Icons.share),
                label: Text('Share the image above'),
                onPressed: () => shareImage(),
              width: 200,
              child: Row(
                children: <Widget>[
                  Image.asset('images/bat1.jpg',height: 80),
                  Image.asset('images/bat2.jpg',height: 80),
                  Image.asset('images/bat3.jpg',height: 80)
              child: RaisedButton.icon(
                icon: Icon(Icons.share),
                label: Text('Share the images above'),
                onPressed: () => shareMultipleImages(),

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  sams_flutter_share: ^0.0.2

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:sams_flutter_share/sams_flutter_share.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Mar 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/sams_flutter_share.dart.

Run flutter format to format lib/sams_flutter_share.dart.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
path_provider ^1.5.1 1.6.5
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
path_provider_macos 0.0.4
path_provider_platform_interface 1.0.1
platform 2.2.1
plugin_platform_interface 1.0.2
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies