share_social_media_plugin 1.1.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 79

N|Social media

Share social media plugin

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.

Share text in your social media.

  • Line (Android / iOS) πŸ‘
  • Twitter (Android / iOS) πŸ‘
  • Instagram (Android /iOS) πŸ‘

Example #

Share in Line.

 await ShareSocialMediaPlugin.shareLine("My share text");

Share in Twitter

//Set keys
final twitterLogin = new ShareSocialMediaPlugin(
      consumerKey: "consumerKey",
      consumerSecret: 'consumerSecret');

             RaisedButton(
                        child: Text(titleTwitterButton, style: TextStyle(fontSize: 20)),
                        onPressed: () async {
                        //Platform in Android
                          if (Platform.isAndroid) {
                            var result = await twitterLogin.shareTwitter("conectado desde plugin");
                            print(result);
                            if(result != null){
                              if (result == "success"){
                                print("success!");
                              }else{
                                print("fail");
                              }
                            }
                          }
                          //Platform in iOS
                          else if (Platform.isIOS) {
                            var sessionTwitter = await twitterLogin.currentSessionIOS();
                            var tweet = await twitterLogin.shareTwitteriOS(
                                sessionTwitter["outhToken"],
                                sessionTwitter["oauthTokenSecret"],
                                "test cpmplete future",
                                twitterLogin.consumerKey,
                                twitterLogin.consumerSecret);

                            final response = json.decode(tweet.body);
                            if (response['text'] != null) {
                               print("success");
                            }else{
                              print("fail");
                            }
                          }
                        },
                      ),

**Note For iOS Twitter In plist add:

	<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>TwitterLoginSampleOAuth</string>
			</array>
		</dict>
	</array>

Add in your Delegate

ios/Runner/AppDelegate.swift

 import OAuthSwift

 @UIApplicationMain
 @objc class AppDelegate: FlutterAppDelegate {
   override func application(
     _ application: UIApplication,
     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
   ) -> Bool {
     GeneratedPluginRegistrant.register(with: self)
     return super.application(application, didFinishLaunchingWithOptions: launchOptions)
   }
     //Add this
     override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        if (url.host == "oauth-callback") {
           OAuthSwift.handle(url: url)
         }else{
           OAuthSwift.handle(url: url)
         }
         return true
     }
 }

!IMPORTANT

In your developer.twitter.com app , you need add the next callback

-TwitterLoginSampleOAuth://

-twittersdk://

Instagram- Share stories (ios /android) #

##Android Read some image from flutter assets

 RaisedButton(
              onPressed: () async {
                  await ShareSocialMediaPlugin.shareInstagram("hello","assets/nofumar.jpg");
              },
              child: Text('Share in Instagram', style: TextStyle(fontSize: 20)),
            )

Public image from album phone

 RaisedButton(
              onPressed: () async {
                 await ShareSocialMediaPlugin.shareInstagramAlbum();
              },
              child: Text('Share in Instagram from album', style: TextStyle(fontSize: 20)),
            )

(For any case add this code in your AndroidManifest.xml)

android/app/src/main/AndroidManifest.xml

   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

iOS #

πŸ”₯

 RaisedButton(
              onPressed: () async {
              //shareInstagram("message","image","background");
                  await ShareSocialMediaPlugin.shareInstagram("hello","assets/my_image.jpg","assets/background");
              },
              child: Text('Share in Instagram', style: TextStyle(fontSize: 20)),
            )

In your plist add

 <key>LSApplicationQueriesSchemes</key>
        <array>
            <string>instagram-stories</string>
        </array>

**The user needs to have instagram installed

Thank you!! 🍺🍺🍺🍺🍺🍺

πŸ’– γ‚γ‚ŠγŒγ¨γ†γ”γ–γ„γΎγ™

γŠγ‘γ•γ‚“

γΎγ‚Šγ‚‚γ•γ‚“

まさきさん

をキコさん

γ‚γ‚ŠγŒγ¨γ† Driglo ✨

Thank you for your repo https://github.com/bodnarrr/flutter_twitter_login/blob/master/android/src/main/java/com/bodnarrr/fluttertwitterlogin/fluttertwitterlogin/TwitterLoginPlugin.java

0.0.1 #

  • Line Share *Share text for your contacts in line

1.0.0 #

  • Fix some license *Share text for your contacts in line

1.0.1 #

  • Readme

1.0.2 #

  • Readme

1.0.3 #

  • Only in Android
  • Log in Twitter
  • LogOut Twitter
  • Share text in Twitter

1.0.4 #

  • Readme

1.0.5 #

  • Add support for iOS Twitter share

1.0.6 #

** Instagram stories from album ** Instagram stories from assets

1.0.7 #

** Instagram stories from album Android ** Instagram stories from assets ios/Android

1.0.8 #

** Fix readme

1.09 #

** Fix dependencies

1.1.0 #

** fix readme

1.1.1 #

** fix stack android

1.1.2 #

** response twitter ** add background image in iOS for history instagram ** add fix problem in function android deprecated ** response future in line

#1.1.5 ** update flutter_twitter_ab#-installing-tab- 1.0.1 > 1.1.1

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:http/src/response.dart';
import 'dart:io' show Platform;
import 'package:share_social_media_plugin/share_social_media_plugin.dart';
import 'package:flutter/services.dart';
import 'dart:convert';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final twitterLogin = ShareSocialMediaPlugin(
      consumerKey: '',
      consumerSecret: '');
  var titleTwitterButton = "Connect Twitter";

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    twitterLogin.isSessionActive.then((value) {
      if (value) {
        titleTwitterButton = "Share in twitter";
      } else {
        titleTwitterButton = "Connect to Twitter";
      }
      setState(() {});
    });

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Share social media'),
        ),
        body: Column(
          children: <Widget>[
            RaisedButton(
              onPressed: () async {
                try {
                  var result = await ShareSocialMediaPlugin.shareLine(
                      "http://www.google.com");
                  print(result);
                } on PlatformException catch (e) {
                  print("sucedio un error");
                }
              },
              child: Text('Share in Line', style: TextStyle(fontSize: 20)),
            ),
            RaisedButton(
              child: Text(titleTwitterButton, style: TextStyle(fontSize: 20)),
              onPressed: () async {
                if (Platform.isAndroid) {
                  var result =
                      await twitterLogin.shareTwitter("conectado desde plugin");
                  print(result);
                  if (result != null) {
                    if (result == "success") {
                      print("success!");
                    } else {
                      print("fail");
                    }
                  }
                } else if (Platform.isIOS) {
                  var sessionTwitter = await twitterLogin.currentSessionIOS();
                  var tweet = await twitterLogin.shareTwitteriOS(
                      sessionTwitter["outhToken"],
                      sessionTwitter["oauthTokenSecret"],
                      "test cpmplete future",
                      twitterLogin.consumerKey,
                      twitterLogin.consumerSecret);

                  final response = json.decode(tweet.body);
                  if (response['text'] != null) {
                    print("success");
                  } else {
                    print("fail");
                  }
                }
              },
            ),
            RaisedButton(
              onPressed: () async {
                await ShareSocialMediaPlugin.shareInstagram(
                    "hello", "assets/nofumar.jpg", "assets/logo2323.png");
              },
              child: Text('Share in Instagram', style: TextStyle(fontSize: 20)),
            ),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  share_social_media_plugin: ^1.1.5

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

We analyzed this package on Apr 7, 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 issues and suggestions

Document public APIs. (-0.17 points)

240 out of 247 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/twitter_client.dart. (-0.50 points)

Analysis of lib/twitter_client.dart reported 1 hint:

line 314 col 9: The value of the local variable 'tweet' isn't used.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
crypto ^2.0.6 2.1.4
flutter 0.0.0
http ^0.12.0+1 0.12.0+4
intl 0.16.1 0.16.1
random_string 2.0.1 2.0.1
Transitive dependencies
async 2.4.1
charcode 1.1.3
collection 1.14.11 1.14.12
convert 2.1.1
http_parser 3.1.4
meta 1.1.8
path 1.6.4
pedantic 1.9.0
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test