Search code examples
flutterdartwhatsapp

ERR_UNKNOWN_RL_SCHEME whatsapp link


im trying to link whatsapp with this function, i already try many url options but nothing works

    static Future launchThisUrl(url) async {
    Uri dataUrl = Uri.parse(url!);

    if (await canLaunchUrl(dataUrl)) {
      await launchUrl(dataUrl);
    } else {
      throw 'Could not launch $dataUrl';
    }
  }

  static launchWhatsApp(
      {required String phone, required String message}) async {
    String url = '';
    if (Platform.isAndroid) {
      url = "https://wa.me/$phone?text=${Uri.parse(message)}";
      log('ANDROID == $url');
    } else {
      log('IOS');
      url = "https://wa.me/send?phone=$phone&text=${Uri.parse(message)}";
    }
    await launchThisUrl(url);
  }

but it always return this

enter image description here


Solution

  • The url in my case that works, looks like this. Try this:

    https://wa.me/${phone}/?text=hello