Flutter: Adding share options when using the Share plugin
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
What I'm trying to do is allow users to share a post they see on my app. I am using the Flutter Share plugin, but I'm having some difficulty with it and have been looking all over, including the docs which aren't very good.
I have the share button itself working - so the panel will rise up and be displayed to the user. However, it doesn't provide them with any useful option and I can't find how to add those options, such as Facebook, Twitter, Email, Text, etc..
Here is my code, and a picture to show what is happening:
// build method from another class
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: Firestore.instance.collection('stories').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const Text('Loading...');
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) =>
_buildEventCards(context, snapshot.data.documents[index]),
);
},
);
}
class ShareButton extends StatelessWidget {
const ShareButton({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return FlatButton(
child: Text(
'Share',
style: TextStyle(
color: Color.fromRGBO(245, 93, 62, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
final RenderBox box = context.findRenderObject();
Share.share('Hello this is a test',
sharePositionOrigin:
box.localToGlobal(Offset.zero) &
box.size);
},
);
}
}
Sorry the picture is so big, but I would like to add sharing options such as Facebook, Twitter, Email, Messages, etc.
Any help would be much appreciated!
dart flutter
add a comment |
What I'm trying to do is allow users to share a post they see on my app. I am using the Flutter Share plugin, but I'm having some difficulty with it and have been looking all over, including the docs which aren't very good.
I have the share button itself working - so the panel will rise up and be displayed to the user. However, it doesn't provide them with any useful option and I can't find how to add those options, such as Facebook, Twitter, Email, Text, etc..
Here is my code, and a picture to show what is happening:
// build method from another class
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: Firestore.instance.collection('stories').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const Text('Loading...');
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) =>
_buildEventCards(context, snapshot.data.documents[index]),
);
},
);
}
class ShareButton extends StatelessWidget {
const ShareButton({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return FlatButton(
child: Text(
'Share',
style: TextStyle(
color: Color.fromRGBO(245, 93, 62, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
final RenderBox box = context.findRenderObject();
Share.share('Hello this is a test',
sharePositionOrigin:
box.localToGlobal(Offset.zero) &
box.size);
},
);
}
}
Sorry the picture is so big, but I would like to add sharing options such as Facebook, Twitter, Email, Messages, etc.
Any help would be much appreciated!
dart flutter
add a comment |
What I'm trying to do is allow users to share a post they see on my app. I am using the Flutter Share plugin, but I'm having some difficulty with it and have been looking all over, including the docs which aren't very good.
I have the share button itself working - so the panel will rise up and be displayed to the user. However, it doesn't provide them with any useful option and I can't find how to add those options, such as Facebook, Twitter, Email, Text, etc..
Here is my code, and a picture to show what is happening:
// build method from another class
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: Firestore.instance.collection('stories').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const Text('Loading...');
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) =>
_buildEventCards(context, snapshot.data.documents[index]),
);
},
);
}
class ShareButton extends StatelessWidget {
const ShareButton({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return FlatButton(
child: Text(
'Share',
style: TextStyle(
color: Color.fromRGBO(245, 93, 62, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
final RenderBox box = context.findRenderObject();
Share.share('Hello this is a test',
sharePositionOrigin:
box.localToGlobal(Offset.zero) &
box.size);
},
);
}
}
Sorry the picture is so big, but I would like to add sharing options such as Facebook, Twitter, Email, Messages, etc.
Any help would be much appreciated!
dart flutter
What I'm trying to do is allow users to share a post they see on my app. I am using the Flutter Share plugin, but I'm having some difficulty with it and have been looking all over, including the docs which aren't very good.
I have the share button itself working - so the panel will rise up and be displayed to the user. However, it doesn't provide them with any useful option and I can't find how to add those options, such as Facebook, Twitter, Email, Text, etc..
Here is my code, and a picture to show what is happening:
// build method from another class
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: Firestore.instance.collection('stories').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const Text('Loading...');
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) =>
_buildEventCards(context, snapshot.data.documents[index]),
);
},
);
}
class ShareButton extends StatelessWidget {
const ShareButton({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return FlatButton(
child: Text(
'Share',
style: TextStyle(
color: Color.fromRGBO(245, 93, 62, 1.0)),
),
color: Colors.grey[100],
onPressed: () {
final RenderBox box = context.findRenderObject();
Share.share('Hello this is a test',
sharePositionOrigin:
box.localToGlobal(Offset.zero) &
box.size);
},
);
}
}
Sorry the picture is so big, but I would like to add sharing options such as Facebook, Twitter, Email, Messages, etc.
Any help would be much appreciated!
dart flutter
dart flutter
asked Nov 23 '18 at 14:55
GarrettGarrett
478421
478421
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I feel kind of dumb now because I now realize how this Share thing works, but this is definitely something that could be confusing for beginners or people using simulators on their computers wondering what's happening..
Everything works fine the reason I couldn't get anything to show up in the Share panel is because I was testing with simulator app on my computer which doesn't have the mail app, isn't associated with my phone number, isn't logged into Facebook / Twitter, and doesn't have any other apps that could be shared through.
All you have to do is test your app on your actual device and then what ever apps / accounts you're logged into will show up here and you'll be able to share stuff.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53448880%2fflutter-adding-share-options-when-using-the-share-plugin%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I feel kind of dumb now because I now realize how this Share thing works, but this is definitely something that could be confusing for beginners or people using simulators on their computers wondering what's happening..
Everything works fine the reason I couldn't get anything to show up in the Share panel is because I was testing with simulator app on my computer which doesn't have the mail app, isn't associated with my phone number, isn't logged into Facebook / Twitter, and doesn't have any other apps that could be shared through.
All you have to do is test your app on your actual device and then what ever apps / accounts you're logged into will show up here and you'll be able to share stuff.
add a comment |
I feel kind of dumb now because I now realize how this Share thing works, but this is definitely something that could be confusing for beginners or people using simulators on their computers wondering what's happening..
Everything works fine the reason I couldn't get anything to show up in the Share panel is because I was testing with simulator app on my computer which doesn't have the mail app, isn't associated with my phone number, isn't logged into Facebook / Twitter, and doesn't have any other apps that could be shared through.
All you have to do is test your app on your actual device and then what ever apps / accounts you're logged into will show up here and you'll be able to share stuff.
add a comment |
I feel kind of dumb now because I now realize how this Share thing works, but this is definitely something that could be confusing for beginners or people using simulators on their computers wondering what's happening..
Everything works fine the reason I couldn't get anything to show up in the Share panel is because I was testing with simulator app on my computer which doesn't have the mail app, isn't associated with my phone number, isn't logged into Facebook / Twitter, and doesn't have any other apps that could be shared through.
All you have to do is test your app on your actual device and then what ever apps / accounts you're logged into will show up here and you'll be able to share stuff.
I feel kind of dumb now because I now realize how this Share thing works, but this is definitely something that could be confusing for beginners or people using simulators on their computers wondering what's happening..
Everything works fine the reason I couldn't get anything to show up in the Share panel is because I was testing with simulator app on my computer which doesn't have the mail app, isn't associated with my phone number, isn't logged into Facebook / Twitter, and doesn't have any other apps that could be shared through.
All you have to do is test your app on your actual device and then what ever apps / accounts you're logged into will show up here and you'll be able to share stuff.
answered Nov 23 '18 at 16:48
GarrettGarrett
478421
478421
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53448880%2fflutter-adding-share-options-when-using-the-share-plugin%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown