sm_network_proxy 0.1.0 copy "sm_network_proxy: ^0.1.0" to clipboard
sm_network_proxy: ^0.1.0 copied to clipboard

Optional Android and iOS system proxy support for sm_network.

sm_network_proxy #

English 简体中文

Optional Android and iOS system proxy support for sm_network. This package is maintained alongside the core package in the sm_network repository, so the core package can remain pure Dart.

Installation #

flutter pub add sm_network sm_network_proxy

Usage #

import 'package:flutter/widgets.dart';
import 'package:sm_network/sm_network.dart';
import 'package:sm_network_proxy/sm_network_proxy.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  Http.shared.config(
    httpClientAdapter: await SystemProxy.createAdapter(),
  );
}

Each createAdapter() call reads the current system proxy. If no valid system proxy is configured, the returned adapter connects directly.

HTTP/2 #

Pass http2: true when the client uses HTTP/2:

final adapter = await SystemProxy.createAdapter(http2: true);

If the system proxy changes while the app is running, read it again and replace the adapter:

Http.dio.httpClientAdapter = await SystemProxy.createAdapter();

Platforms #

  • Android reads the Java system HTTP proxy properties.
  • iOS reads the system proxy configuration.
  • Other platforms are not implemented by this plugin; configure a core package adapter directly instead.

Example #

The Flutter example combines the system proxy with Session<Person> response conversion:

cd example
flutter pub get
flutter run
0
likes
160
points
102
downloads

Documentation

API reference

Publisher

verified publishershay.wang

Weekly Downloads

Optional Android and iOS system proxy support for sm_network.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

dio, dio_http2_adapter, flutter

More

Packages that depend on sm_network_proxy

Packages that implement sm_network_proxy