supportsMode method

  1. @override
Future<bool> supportsMode(
  1. PreferredLaunchMode mode
)

Returns true if the given launch mode is supported by the current implementation.

Clients are not required to query this, as implementations are strongly encouraged to automatically fall back to other modes if a launch is requested using an unsupported mode (matching historical behavior of the plugin, and thus maximizing compatibility with existing code).

Implementation

@override
Future<bool> supportsMode(PreferredLaunchMode mode) async {
  switch (mode) {
    case PreferredLaunchMode.platformDefault:
    case PreferredLaunchMode.inAppWebView:
    case PreferredLaunchMode.inAppBrowserView:
    case PreferredLaunchMode.externalApplication:
    case PreferredLaunchMode.externalNonBrowserApplication:
      return true;
    // Default is a desired behavior here since support for new modes is
    // always opt-in, and the enum lives in a different package, so silently
    // adding "false" for new values is the correct behavior.
    // ignore: no_default_cases
    default:
      return false;
  }
}