detect_proxy_setting 0.0.6 copy "detect_proxy_setting: ^0.0.6" to clipboard
detect_proxy_setting: ^0.0.6 copied to clipboard

This package detect proxy setting for http. Supported os are Android, iOS, MacOS, Windows.

pub package

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
1
likes
140
points
123
downloads

Publisher

verified publisherplayon.jp

Weekly Downloads

2024.07.06 - 2025.01.18

This package detect proxy setting for http. Supported os are Android, iOS, MacOS, Windows.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, proxy_setting_android, proxy_setting_ios, proxy_setting_macos, proxy_setting_platform_interface, proxy_setting_windows

More

Packages that depend on detect_proxy_setting