我想启动定制的动态链接。
我有从数据库中加载字符串文本的getter,这个字符串文本是用户输入的,其中有IG用户名bio是IG用户名exsample @instagram
String getBio(String bio) {
if (widget.isMyProfile) {
return bio;
} else if (bio == "") {
return "";
} else {
return bio;
}}
我想有静态链接"**https://instagram.com/**;",其中的链接结束将是动态instagram用户名示例:'https://instagram.com/instagram';
_launchURLIG() async {
const url = 'https://instagram.com/';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}}
=====类似的东西。https://instagram.com‘+ getBio
_launchURLIG() async {
const url = 'https://instagram.com' + getBio ;
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}}
发布于 2022-02-17 18:27:56
您应该通过配置文件作为函数的参数。
_launchURLIG(String userId) async {
String url = 'https://instagram.com/' + userId ;
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}发布于 2022-02-17 19:58:06
也许您需要这个包来运行链接:https://pub.dev/packages/url_launcher
https://stackoverflow.com/questions/71163079
复制相似问题