79436277

Date: 2025-02-13 13:14:29
Score: 1.5
Natty:
Report link

i implementing this code in my project annd is working fine

onTap: () async { if (shareList[index]['title'] == "Whatsapp") { final url = "https://wa.me/?text=${articleLink.toString()}"; if (await canLaunchUrl(Uri.parse(url))) { await launchUrl(Uri.parse(url)); Navigator.pop(context); } else { throw 'Could not launch $url'; } } else if (shareList[index]['title'] == "Facebook") { final facebookPageUrl = Uri.parse( "fb://facewebmodal/f?href=https://www.facebook.com/$articleLink"); if (await canLaunchUrl(facebookPageUrl)) { await launchUrl(facebookPageUrl, mode: LaunchMode.externalApplication); Navigator.pop(context); } else { final fallbackUrl = Uri.parse( "https://www.facebook.com/$articleLink"); Navigator.pop(context); if (await canLaunchUrl(fallbackUrl)) { await launchUrl(fallbackUrl, mode: LaunchMode.externalApplication); } else { throw 'Could not launch Facebook URL'; } } } else if (shareList[index]['title'] == "Gmail") { final Uri emailUri = Uri( scheme: 'mailto', path: '', query: Uri.encodeFull( 'subject=Send a Article Link&body=$articleLink'), ); if (await canLaunchUrl(emailUri)) { await launchUrl(emailUri); Navigator.pop(context); } else { throw 'Could not launch email app'; } } else if (shareList[index]['title'] == "LinkedIn") { final profileUrl = Uri.parse( "https://www.linkedin.com/sharing/share-offsite/?url=${Uri.encodeComponent(articleLink)}"); if (await canLaunchUrl(profileUrl)) { await launchUrl(profileUrl, mode: LaunchMode.externalApplication); Navigator.pop(context); } else { throw 'Could not launch LinkedIn profile'; } } else { Clipboard.setData(ClipboardData(text: articleLink)) .then((_) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text("Link copied to clipboard"))); }); // Clipboard.setData(ClipboardData(text: articleLink)); Navigator.pop(context); } },

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Nikita