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
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);
});
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';
}
-
1The 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– SmartakCommented Jan 9, 2022 at 9:38
-
Sorry for misunderstanding your question, please reformat your question and provide more details– AdnanCommented 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.– SmartakCommented Jan 9, 2022 at 10:19