Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Align(
alignment: Alignment.center,
child: Text(
widget.data.judul,
style: TextStyle(
fontSize: 17, fontWeight: FontWeight.bold),
),
),
]),
Padding(
padding: EdgeInsets.symmetric(vertical: 1.h),
child: Column(children: [
Text(
widget.data.penulis,
style: TextStyle(fontSize: 12),
),
Text(
widget.data.waktu,
style: TextStyle(fontSize: 10),
),
]),
),
Padding(
padding: EdgeInsets.symmetric(vertical: 1.h),
child: Text(widget.data.isi)),
)
],
),
),
),
);
}
}
我想在分享内容的按钮上有一个分享按钮 在屏幕内,显示标题和一些描述, data[index].judul 是标题,data[index].isi 是描述
答案 0 :(得分:1)
Container(
margin: EdgeInsets.fromLTRB(16, 32, 16, 16),
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
),
padding: EdgeInsets.fromLTRB(16, 20, 16, 20),
child: Text(
"Share",
style: TextStyle(
fontFamily: "medium",
color: Colors.white,
fontSize: 18,
),
),
onPressed: () async {
Share.share(
data[index].judul.toString(),
subject: data[index].isi.toString()
);
},
),
)
您甚至可以共享文件,在大多数情况下,我们使用 firebase 动态链接共享。 https://pub.dev/packages/firebase_dynamic_links
分享插件:https://pub.dev/packages/share
答案 1 :(得分:0)
这里使用这个插件。
Share plugin
分享:^2.0.1
try {
await Share.share(
'${data[index].judul}',subject:'${data[index].isi}'
);
} on PlatformException {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(
content: Text(
"Platform not support this feature",
textAlign: TextAlign.center,
),
));
} on MissingPluginException {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(
content: Text(
"Feature Not Available",
textAlign: TextAlign.center,
),
));
} catch (er) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(
content: Text("Error: $er"),
));
}
答案 2 :(得分:0)
要将数据从一个应用程序共享到另一个应用程序,您可以使用 share plugin 示例,
Share.share('check out my website https://example.com');
有关更多示例和详细信息,请访问 codewithflutter.com