getProxyForUrl method

  1. @override
Future<Uri?> getProxyForUrl(
  1. Uri url
)
override

Returns the proxy Uri for url, or null for a direct connection.

Implementation

@override
Future<Uri?> getProxyForUrl(Uri url) async {
  final proxy = await methodChannel.invokeMethod<String>(
    'getProxyForUrl',
    <String, dynamic>{'url': url.toString()},
  );

  // A null, empty, or explicit "DIRECT" response means no proxy.
  if (proxy == null || proxy.isEmpty || proxy.toUpperCase() == 'DIRECT') {
    return null;
  }

  return Uri.tryParse(proxy);
}