ios – flutter android : fix net::err_unknown_url_scheme whatsapp link on flutter webview

Using the Webview Flutter package, I cannot directly redirect to WhatsApp or any other link in the Webview view. Where am I going wrong please help! The project has WhatsApp redirection in the Web view, but it gives an error in the mobile app.
I tried to solve the question by referring to similar problems on Stack Overflow, but I could not solve it. The URLs do not work. I appreciate your solution.

import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:webview_flutter/webview_flutter.dart';

class Anasayfa extends StatefulWidget {
  get keepAlive => true;

  _AnasayfaState createState() => _AnasayfaState();

class _AnasayfaState extends State<Anasayfa> with AutomaticKeepAliveClientMixin {
  WebViewController controller = WebViewController()
    ..setBackgroundColor(const Color(0x00000000))
        onProgress: (
          int progress,
        ) {
          // Update loading bar.
        onPageStarted: (String url) {},
        onPageFinished: (String url) {},
        onWebResourceError: (WebResourceError error) {},
        onNavigationRequest: (NavigationRequest request) async {
          if (request.url.startsWith('')) {
            print('blocking navigation to $request}');
            List<String> urlSplitted = request.url.split("&text=");

            String phone = "905362936408";
            String message = urlSplitted.last.toString().replaceAll("%20", " ");

            await _launchURL("$phone/?text=${Uri.parse(message)}");
            return NavigationDecision.prevent;

          print('allowing navigation to $request');
          return NavigationDecision.navigate;

  bool get wantKeepAlive => widget.keepAlive;
  Widget build(BuildContext context) {;
    return Scaffold(
      body: WebViewWidget(
        controller: controller,

_launchURL(String url) async {
  if (await canLaunch(url)) {
    await launch(url);
  } else {
    throw 'Could not launch $url';

Latest articles


Related articles

Leave a reply

Please enter your comment!
Please enter your name here