1

so I´ve been working in a webview project for my php code, the thing is, I have some redirects inside the app, like email, phone and others.

The problema is it doesnt seen to work been trying to use url_launcher, but even with this and a code that seens right, Im stil get the error net::ERR_UNKNOWN_URL_SCHEME.

i have seen this topic Flutter Webview - Opening External Links in Browser or Window but mostly its deprecated, and the new docs doesnt do match for webview

anyway thats the part of my code that is supposed to make it work

class MyNavigationDelegate extends NavigationDelegate {
Future\<Object\> shouldOverrideUrlLoading(
WebViewController controller, NavigationRequest navigation) async {
var uri = Uri.parse(navigation.url);

if (uri.scheme == 'mailto') {
final email = uri.path.substring(1);
final mailtoUrl = 'mailto:$email';
await launchUrl(Uri.parse(mailtoUrl));
return NavigationDecision.prevent;
} else if (uri.scheme == 'tel') {`your text`
final tel = uri.path.substring(1);
final telUrl = 'tel:$tel';
await launchUrl(Uri.parse(telUrl));
return NavigationDecision.prevent;
}

return false;`
}

}

class \_MyHomePageState extends State\<MyHomePage\> {
late final WebViewController controller;`

@override`
void initState() {
controller = WebViewController();
controller.setJavaScriptMode(JavaScriptMode.unrestricted);
controller.setNavigationDelegate(MyNavigationDelegate());
controller.loadRequest(Uri.parse(" my url "));
addFileSelectionListener();
super.initState();
}\

1 Answer 1

0

you wrongly formatted code block , re-post the code with right format

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.