-
Notifications
You must be signed in to change notification settings - Fork 56
/
share.dart
45 lines (41 loc) · 1.29 KB
/
share.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import 'package:flutter/material.dart';
import 'package:share/share.dart';
class SharePage extends StatefulWidget {
final String title;
SharePage(this.title, {Key key}) : super(key: key);
@override
_SharePageState createState() => _SharePageState();
}
class _SharePageState extends State<SharePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(widget.title)),
body: SingleChildScrollView(
padding: const EdgeInsets.all(10),
child: Column(children: <Widget>[
ButtonBar(
alignment: MainAxisAlignment
.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
// Button集合
RaisedButton(
child: Text('文本分享1'),
onPressed: share1,
),
RaisedButton(
child: Text('文本分享2'),
onPressed: share2,
),
],
),
])));
}
void share1() {
Share.share('这是我分享的内容: https://baidu.com');
}
void share2() {
Share.share('这是我分享的内容: https://baidu.com', subject: "这是副标题");
}
}