Túlio Calazans
Túlio Calazans

Reputation: 318

launch method in Flutter url_launcher dart package is deprecated, but launchURL does not have forceSafariVC parameter

"launch" method in Flutter url_launcher dart package is deprecated, and it needs to be replaced to launchURL. But launchURL method does not have forceSafariVC parameter.

How would the migration to this new method look like considering the forceSafariVC parameter?

Upvotes: 2

Views: 4877

Answers (2)

Michele Volpato
Michele Volpato

Reputation: 760

You need to use LaunchMode. In general (but not in all cases):

  • forceSafariVC: false translates to mode: LaunchMode.externalApplication.

  • forceSafariVC: true translates to mode: LaunchMode.inAppWebView.

If your app has also non-mobile targets (macOS, Windows, Linux, Web), then you might want to use different modes.

If you need to handle universal links, then you might want to use

    final nativeAppLaunchSucceeded = await launchUrl(
      url,
      mode: LaunchMode.externalNonBrowserApplication,
    );
    if (!nativeAppLaunchSucceeded) {
      await launchUrl(
        url,
        mode: LaunchMode.inAppWebView,
      );
    }

See the official example.

Upvotes: 11

user18309290
user18309290

Reputation: 8360

Use LaunchMode instead.

replace forceSafariVC and forceWebView with LaunchMode, which makes the API platform-neutral, and standardizes the default behavior between Android and iOS.

See changelog.

Upvotes: 2

Related Questions