share_social_media_plugin 1.0.8 share_social_media_plugin: ^1.0.8 copied to clipboard
Share social media plugin, share Line, Twitter, FB, Instagram and more!, I try develop step for step. Any suggestion please contact me.
import 'package:flutter/material.dart';
import 'dart:io' show Platform;
import 'package:share_social_media_plugin/share_social_media_plugin.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final twitterLogin = new ShareSocialMediaPlugin(
consumerKey: "YOUR CONSUMER KEY",
consumerSecret: 'YOUR CONSUMER SECRECT');
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 {
await ShareSocialMediaPlugin.shareLine("http://www.google.com");
},
child: Text('Share in Line', style: TextStyle(fontSize: 20)),
),
RaisedButton(
child: Text(titleTwitterButton, style: TextStyle(fontSize: 20)),
onPressed: () async {
if (Platform.isAndroid) {
twitterLogin.shareTwitter("conectado desde plugin");
} else if (Platform.isIOS) {
var sessionTwitter = await twitterLogin.currentSessionIOS();
var tweet = await twitterLogin.shareTwitteriOS(
sessionTwitter["outhToken"],
sessionTwitter["oauthTokenSecret"],
"ありがとう",
twitterLogin.consumerKey,
twitterLogin.consumerSecret);
print(tweet.body.toString());
}
},
),
RaisedButton(
onPressed: () async {
await ShareSocialMediaPlugin.shareInstagram("hello","assets/nofumar.jpg");
},
child: Text('Share in Instagram', style: TextStyle(fontSize: 20)),
),
],
),
),
);
}
}