launchBrowserTab function

Future<String> launchBrowserTab(
  1. Uri uri, {
  2. String? redirectUri,
})

Launches a given url with platform-specific default browser tab.

Implementation

Future<String> launchBrowserTab(Uri uri, {String? redirectUri}) async {
  if (uri.scheme != 'http' && uri.scheme != 'https') {
    throw KakaoClientException(
      'Default browsers only supports URL of http or https scheme.',
    );
  }
  var args = {"url": uri.toString(), "redirect_uri": redirectUri};
  args.removeWhere((k, v) => v == null);
  final redirectUriWithParams =
      await _channel.invokeMethod<String>("launchBrowserTab", args);

  if (redirectUriWithParams != null) return redirectUriWithParams;
  throw KakaoClientException(
      "OAuth 2.0 redirect uri was null, which should not happen.");
}