ComaXD EA1
ComaXD EA1

Reputation: 415

Launch link in flutter

i would like to launch custom dynamic links..

i have getter which load string text from database, this string text is user input with them IG username bio is IG username, exsample @instagram

 String getBio(String bio) {
if (widget.isMyProfile) {
  return bio;
} else if (bio == "") {
  return "";
} else {
  return bio;
}

}

i want to have static link "**https://instagram.com/**;" where end of link will be dynamic instagram user name example: 'https://instagram.com/instagram';

_launchURLIG() async {
const url = 'https://instagram.com/';
if (await canLaunch(url)) {
  await launch(url);
} else {
  throw 'Could not launch $url';
}

}

===== something like this. 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';
}

}

Upvotes: 1

Views: 887

Answers (2)

Abdulrahim Klis
Abdulrahim Klis

Reputation: 494

Maybe you need this package to run link: https://pub.dev/packages/url_launcher

Upvotes: 0

Carlos Sandoval
Carlos Sandoval

Reputation: 867

You should past profile as a parameter to your function

_launchURLIG(String userId) async {
String url = 'https://instagram.com/' + userId ;
if (await canLaunch(url)) {
  await launch(url);
} else {
  throw 'Could not launch $url';
}

Upvotes: 1

Related Questions