Home > Blockchain >  Flutter: Can't open telegram channel from URL_LUNCHER
Flutter: Can't open telegram channel from URL_LUNCHER

Time:10-04

I want to direct open to telegram channel using url_luncher from my flutter app. currently, I can open the telegram app but it does not direct to the channel.

Is there any configure would need to achieve this?

GestureDetector(
    onTap: () async {
      var url = Uri.parse("tg://t.me/channel_name");
      if (await canLaunchUrl(url)) {
        await launchUrl(url);
      }
    },
    child: ListTile(
      visualDensity: const VisualDensity(vertical: -4),
      minLeadingWidth: leadingTxtSpace,
      leading: const CircleAvatar(
        radius: 15,
        backgroundColor: Colors.blueAccent,
        child: Icon(Icons.telegram_outlined, color: Colors.white),
      ),
      title: Text(
        "Telegram",
        style: Theme.of(context).textTheme.bodySmall,
      ),
    ),
  ),

CodePudding user response:

In my case I used this link, try that too . https://t.me/user_name It work in my case..

CodePudding user response:

You can adapt the example yourself

IconButton(
                          onPressed: () async {
                            await launch(
                              "https://t.me/Your link",
                              forceSafariVC: false,
                              forceWebView: false,
                              headers: <String, String>{
                                'my_header_key': 'my_header_value'
                              },
                            );
                          },
                          icon: Icon(
                            FontAwesomeIcons.telegram,
                            color: Colors.blue,
                          ),
                          iconSize: 45,
                        ),
  • Related