0

I am creating a webview app using flutter_webview_plugin. I am stack at allowing the app to launch phone call and mailto links. When I use webview_flutter I get the bottom menus and the address bar at the top does not disappear

2 Answers 2

1

I have managed to come up with this simple solution, just add these few lines of code in your initState, you can add 'mailto:' and 'sms' if necessary.

final flutterWebviewPlugin = new FlutterWebviewPlugin();
flutterWebviewPlugin.onUrlChanged.listen((String url) {
  if (url.contains("tel:")) launch(url);
});
0

try using the url launcher package

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

const String _url = 'mailto:[email protected]';

void main() => runApp(
      const MaterialApp(
        home: Material(
          child: Center(
            child: ElevatedButton(
              onPressed: _launchURL,
              child: Text('Show Flutter homepage'),
            ),
          ),
        ),
      ),
    );

void _launchURL() async {
  if (!await launch(_url)) throw 'Could not launch $_url';
}
3
  • 1
    The links (tel and/or mailto) are embedded within the website that will be launched using my app, so I need when call button is clicked to open call or mail
    – Smartak
    Commented Jan 9, 2022 at 9:38
  • Sorry for misunderstanding your question, please reformat your question and provide more details
    – Adnan
    Commented Jan 9, 2022 at 9:49
  • Thanks Adnan. Well it's like this, I am creating a webview app using flutter_webview_plugin that will open a website which has a phone call button which when tapped from the App should allow a call to a number attached. I am stack at allowing the app to launch phone call.
    – Smartak
    Commented Jan 9, 2022 at 10:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.