A dart:io HttpClient accepts its proxy decision through findProxy. The callback returns a PAC-style directive:

import 'dart:io';

final client = HttpClient()
  ..findProxy = (_) => 'PROXY proxy.example.net:8080';

Use this client for the application’s requests. Returning http://proxy.example.net:8080 is the wrong format for this callback; PROXY followed by the host and port is the supported form. For permitted public requests, take an HTTP candidate from the HTTP proxy list and format it as that directive.

The callback receives the destination URI, so it can return DIRECT for a deliberate bypass. A result such as PROXY proxy.example.net:8080; DIRECT also permits a direct fallback when the proxy cannot be used. Omit DIRECT when that fallback is unwanted.

Without a findProxy function, this API uses direct connections. Applications wanting environment-based selection can assign HttpClient.findProxyFromEnvironment to the callback instead.

This applies to Flutter code using dart:io on supported native platforms. Flutter Web requests use the browser’s networking facilities and require the browser’s proxy policy.

Allakkat attuumassuteqartut