Search packages, repositories and app categories

Package detailsv0.1.0

system_proxy

A Flutter Plugin to get system plugin. Use to set dart HttpClient proxy for grabing requests.

AndroidiOS
30-day downloads
8.2K
Likes
23
Pub points
150

Install package

flutter pub add system_proxy

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The system_proxy package is a Flutter plugin that enables access to the system's configured proxy settings on Android and iOS. It allows developers to retrieve the system proxy configuration and apply it to Dart's HttpClient, ensuring network requests respect the device's network environment. This is particularly useful for apps that need to operate behind corporate or restricted networks where proxy settings are mandatory. The plugin simplifies integration by providing a straightforward API to extract proxy details like host, port, and exclusion rules.

Use cases

  • Accessing system proxy settings in enterprise apps
  • Configuring HttpClient with system proxy
  • Ensuring compliance with corporate network policies
  • Handling proxy configurations automatically on Android and iOS
  • Enabling internet access in restricted network environments

Key features

  • Retrieves system proxy settings on Android and iOS
  • Supports Dart HttpClient proxy configuration
  • Automatic detection of proxy host and port
  • Handles proxy exclusion lists
  • Cross-platform compatibility

Suitable for

  • Enterprise mobile applications
  • Apps requiring network transparency
  • Developers building tools for restricted networks
  • Projects needing automatic proxy setup
  • Flutter apps deployed in controlled network environments

Considerations

  • Requires appropriate platform permissions
  • May not work if system proxy is not configured
  • Limited to HTTP/HTTPS proxy settings
  • No support for SOCKS proxies
  • Depends on correct system-level proxy configuration

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

system_proxy

A Flutter Plugin to get system proxy setting. It is used to proxy for Flutter and Dart HttpClient request。Because Dart HttpClient does not adapt the system proxy setting automatically in default, it's difficult to grab requests for testing .

获取系统代理配置。 可用于为flutter的Dart HttpClient的请求设置代理,因为默认Dart请求不会理睬系统代理配置,这对于抓取请求来进行测试等场景造成不小困难。

Getting Started

Install

Please add the plugin to pubspec.yaml.

Caution

It's useful for Android >= 23 .

Usage

Import

import 'package:system_proxy/system_proxy.dart';

Code

// the proxy value likes:  {port: 8899, host: 127.0.0.1}
Map<String, String> proxy = await SystemProxy.getProxySettings();
if (proxy != null) {
    print('proxy $proxy');
}
Setting Proxy for HttpClient
class ProxiedHttpOverrides extends HttpOverrides {
  String _port;
  String _host;
  ProxiedHttpOverrides(this._host, this._port);

  @override
  HttpClient createHttpClient(SecurityContext context) {
    return super.createHttpClient(context)
      // set proxy
      ..findProxy = (uri) {
        return _host != null ? "PROXY $_host:$_port;" : 'DIRECT';
      };
  }
}

void main() async {
  Map<String, String> proxy = await SystemProxy.getProxySettings();
  if (proxy == null) {
    proxy = {
    'host': null,
    'port': null
    };
  }
  HttpOverrides.global = new ProxiedHttpOverrides(proxy['host'], proxy['port']);
  runApp(MyApp());
}

Categories

Source repository

Projects using this package