5
ElevatedButton(
  onPressed: () async {
    const url ='https://www.facebook.com';

    if (await canLaunch(url)) {
      await launch(url,forceWebView: true,enableJavaScript: true);
    } else {
      // can't launch url
    }
  },
);
I/UrlLauncher( 7566): component name for https://www.facebook.com is null
3

1 Answer 1

12

Add the queries for each platform, follow the documentation in this link URL Launcher API Reference

iOS Add any URL schemes passed to canLaunchUrl as LSApplicationQueriesSchemes entries in your Info.plist file.

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>https</string>
  <string>http</string>
</array>

Android Starting from API 30 Android requires package visibility configuration in your AndroidManifest.xml otherwise canLaunchUrl will return false. A element must be added to your manifest as a child of the root element.

<queries>
  <!-- If your app opens https URLs -->
  <intent>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="https" />
  </intent>
  <!-- If your app makes calls -->
  <intent>
    <action android:name="android.intent.action.DIAL" />
    <data android:scheme="tel" />
  </intent>
  <!-- If your sends SMS messages -->
  <intent>
    <action android:name="android.intent.action.SENDTO" />
    <data android:scheme="smsto" />
  </intent>
  <!-- If your app sends emails -->
  <intent>
    <action android:name="android.intent.action.SEND" />
    <data android:mimeType="*/*" />
  </intent>
</queries>

This works for me!

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.