detect_proxy_setting

Creator: coderz1093

Last updated:

0 purchases

detect_proxy_setting Image
detect_proxy_setting Images

Languages

Categories

Add to Cart

Description:

detect proxy setting

This package detect proxy setting for http. Supported os are Android, iOS, MacOS, Windows.
Usage #
To See /tests folder.
Initialize #
class HttpOverridesImpl extends HttpOverrides {
String address = "";
String type = "DIRECT";

@override
String findProxyFromEnvironment(Uri uri, Map<String, String>? environment) {
if (type == "DIRECT") {
return "DIRECT";
}
return 'PROXY $address';
}

Future init() async {
final setting = await proxySetting();
print(setting);
if (setting == null || setting.mode == ProxySettingModeEnum.direct) {
type = "DIRECT";
} else if (setting.mode == ProxySettingModeEnum.proxy &&
setting.proxy.isNotEmpty) {
type = "PROXY";
address = setting.proxy;
}
}
}

Future main() async {
WidgetsFlutterBinding.ensureInitialized();
var httpOverrides = HttpOverridesImpl();
await httpOverrides.init();
HttpOverrides.global = httpOverrides;

runApp(const ProviderScope(child: MyApp()));
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.