如何解决Flutter Hoow add通过电话应用共享此应用吗?
嗨,我如何在我的应用程序中建立链接,如果用户单击它,则使用电子邮件whatsapp等打开此菜单,并且用户可以与我的Play商店链接共享给朋友?
解决方法
您可以使用share软件包。这是完整的代码:
import 'package:flutter/material.dart';
import 'package:share/share.dart';
void main() {
runApp(DemoApp());
}
class DemoApp extends StatefulWidget {
@override
DemoAppState createState() => DemoAppState();
}
class DemoAppState extends State<DemoApp> {
// Your own PlayStore or AppStore Link
String appStoreLink = '<link of app store>';
String subject = '<subject>';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Share Plugin Demo',home: Scaffold(
appBar: AppBar(
title: const Text('Share Plugin Demo'),),body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(24.0),child: Column(
crossAxisAlignment: CrossAxisAlignment.start,children: <Widget>[
const Padding(padding: EdgeInsets.only(top: 12.0)),Builder(
builder: (BuildContext context) {
return RaisedButton(
child: const Text('Share'),onPressed: () => _onShare(context),);
},],)),);
}
_onShare(BuildContext context) async {
final RenderBox box = context.findRenderObject();
await Share.share(appStoreLink,subject: subject,sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。