share_api 0.0.6

  • Readme
  • Changelog
  • Example
  • Installing
  • 73

Flutter Share API Plugin #

Flutter Plugin for sharing contents to social media.

At this moment, this plugin is Android-only. Adding iOS compatibility is the highest priority on the development road map.

Introduction #

This plugin is still in development. Specifications and APIs may change in the subsequent versions. Use this at your own risk.

Available Features #

PlatformAndroidiOSActivity Return ValueNotes
System UIText, Images, and Files
Facebook StoryImages (Background and Sticker)
Instagram StoryImages (Background and Sticker)

Configuration #

Sharing Images and Files #

In order to share files and/or images, you will need to add the following:

Android #

In the android/app/src/main/AndroidManifest.xml, add the following in the manifest/application:

<!-- Add FileProvider in order to access the shared file -->
<provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="${applicationId}.com.albertalrisa.share_api"
        android:exported="false"
        android:grantUriPermissions="true">
    <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_paths" />
</provider>

After adding the File Provider to the manifest, create a file named file_paths.xml in the app/src/main/res/xml folder:

<?xml version="1.0" encoding="utf-8"?>
<paths>
    <cache-path name="images" path="/"/>
</paths>

Usage #

The module is accessed statically by calling ShareApi.via[module].[function]().

The following functions are available:

ModuleFunction
System UIshareText()
shareFile()
shareImage()
FacebookshareToStory()
InstagramshareToStory()

Return Values #

All share functions will return an integer representing the return value of the activity called. If the function does not support obtaining the operation result, ShareResult.undefined or 0x00 is given. Otherwise, the return value will be one of three possible values, which are ok, canceled, and failed. As of now, only Facebook responds with proper value, therefore running the other functions will always return undefined.

There are four possible values:

ValueMeaning
ShareResult.undefined (0x00)The share function does not support return values
ShareResult.ok (0x01)The share function has completed successfully, and the content has been shared
ShareResult.canceled (0x02)The user canceled the share action and return back to the application
ShareResult.failed (0x03)The share function failed to complete. Mostly due to exceptions and other errors

Development Road Map #

  • iOS Compatibility for System UI, Facebook Story, and Instagram Story
  • Examples and Documentation Revamp

Contributing #

Feel free to contribute by opening issues or submitting PRs through GitHub.

Change Log (share_api) #

0.0.6 #

  • iOS Implementation
  • Add iOS implementation for Facebook Story and Instagram Story

0.0.5 #

  • Nullable Problem Fix
  • Fix some variables being declared as nullable where a non-nullable one is expected

0.0.4 #

  • Provider Authorities
  • Change the provider authorities to match the project package name, reducing chance of collision (breaking change)
  • Fix an error caused by Kotlin implicitly convert the arguments from Flutter into a nullable type
  • Documentation is updated to match the new provider authorities setting

0.0.3 #

  • Instagram Share Result Fix and Default Function Removal
  • Instagram should now return ShareResult.unknown instead of ShareResult.canceled (breaking change)
  • Built in platformVersion() function from Flutter default plugin example has been removed (breaking change)
  • Documentation now includes the return value explanation

0.0.2 #

  • Documentation Revamp
  • Improve the documentation, especially on adding FileProvider in Android

0.0.1 #

  • Initial Release
  • Add System UI, Facebook Story, and Instagram Story API functions
  • Compatible only on Android

example/README.md

share_api_example #

Demonstrates how to use the share_api plugin.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

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


dependencies:
  share_api: ^0.0.6

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:share_api/share_api.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
56
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
73
Learn more about scoring.

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

67 out of 67 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/intents/whatsapp.dart. (-1.99 points)

Analysis of lib/intents/whatsapp.dart reported 4 hints:

line 4 col 8: Don't import implementation files from another package.

line 14 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 28 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 57 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (path_provider).

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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
path ^1.6.2 1.6.4
path_provider ^0.4.1 0.4.1 1.4.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8