Flutter Hoow 添加通过 Phone 个应用程序共享此应用程序?
Flutter Hoow add share this App via Phone apps?
你好,我如何在我的应用程序中制作 Link,如果用户点击它打开此菜单,使用电子邮件 whatsapp 等,用户可以与我的 Play 商店分享 link Link 给朋友?
您可以使用 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);
}
}
你好,我如何在我的应用程序中制作 Link,如果用户点击它打开此菜单,使用电子邮件 whatsapp 等,用户可以与我的 Play 商店分享 link Link 给朋友?
您可以使用 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);
}
}