share_social_media_plugin 1.3.7 copy "share_social_media_plugin: ^1.3.7" to clipboard
share_social_media_plugin: ^1.3.7 copied to clipboard

discontinued
PlatformAndroidiOS

Share social media plugin, share Line, Twitter, FB, Instagram and more!, I try develop step for step. Any suggestion please contact me.

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";
  var outhTokenTwitter;
  var oauthTokenSecretTwitter;

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

  @override
  Widget build(BuildContext context) {
    twitterLogin.isSessionActive.then((value) {
      print(value);
    });
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Share social media'),
        ),
        body: Column(
          children: <Widget>[
            ElevatedButton(
              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)),
            ),
            ElevatedButton(
             child: Text('Get image profile Twitter only android'),
              onPressed: () async{
                print(await twitterLogin.getProfileImage());
              },
            ),
            ElevatedButton(
              child: Text('Share in Twitter', style: TextStyle(fontSize: 20)),
              onPressed: () async {
                if (Platform.isAndroid) {
                  twitterLogin.isSessionActive.then((isConnected) async{
                    if (!isConnected){
                      twitterLogin.connectTwitter();
                    }
                    else{
                      var response =
                      await twitterLogin.shareTwitter("example test in android");
                      if (response['text'] != null) {
                        //Success

                      } else {
                        //Fail
                      }
                    }
                  });
                } else if (Platform.isIOS) {
                  if (outhTokenTwitter != null) {
                    var tweet = await twitterLogin.shareTwitteriOS(
                        outhTokenTwitter,
                        oauthTokenSecretTwitter,
                        "test6",
                        twitterLogin.consumerKey,
                        twitterLogin.consumerSecret);

                    final response = json.decode(tweet.body);
                    if (response['text'] != null) {
                      //Success
                      print(tweet.body);
                    } else {
                      //Fail
                      print(tweet.body);
                    }
                  } else {
                    //Connect twitter
                    var sessionTwitter = await twitterLogin.currentSessionIOS();
                    outhTokenTwitter = sessionTwitter["outhToken"];
                    oauthTokenSecretTwitter =
                        sessionTwitter["oauthTokenSecret"];
                  }
                }
              },
            ),
            ElevatedButton(
              onPressed: () async {
                await ShareSocialMediaPlugin.shareInstagram(
                    "hello", "assets/nofumar.jpg", "assets/logo2323.png");
              },
              child: Text('Share in Instagram', style: TextStyle(fontSize: 20)),
            ),
          ],
        ),
      ),
    );
  }
}
18
likes
110
pub points
0%
popularity

Publisher

unverified uploader

Share social media plugin, share Line, Twitter, FB, Instagram and more!, I try develop step for step. Any suggestion please contact me.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

crypto, flutter, http, intl, random_string

More

Packages that depend on share_social_media_plugin