feat: Add cronet and cupertino http client
This should enable http3 on Android, iOS and macOS and make use of the system proxy on Android.
This commit is contained in:
parent
779a84c73e
commit
449972bbd2
6 changed files with 63 additions and 5 deletions
|
|
@ -106,7 +106,7 @@ abstract class ClientManager {
|
|||
|
||||
return Client(
|
||||
clientName,
|
||||
httpClient: CustomHttpClient.createHTTPClient(),
|
||||
httpClient: await CustomHttpClient.createHTTPClient(),
|
||||
verificationMethods: {
|
||||
KeyVerificationMethod.numbers,
|
||||
if (kIsWeb || PlatformInfos.isMobile || PlatformInfos.isLinux)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cronet_http/cronet_http.dart' as cronet;
|
||||
import 'package:cupertino_http/cupertino_http.dart' as cupertino_http;
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/io_client.dart';
|
||||
import 'package:http/retry.dart' as retry;
|
||||
|
|
@ -32,9 +35,20 @@ class CustomHttpClient {
|
|||
return HttpClient(context: context);
|
||||
}
|
||||
|
||||
static http.Client createHTTPClient() => retry.RetryClient(
|
||||
PlatformInfos.isAndroid
|
||||
? IOClient(customHttpClient(ISRG_X1))
|
||||
: http.Client(),
|
||||
static Future<http.Client> createHTTPClient() async {
|
||||
if (PlatformInfos.isAndroid) {
|
||||
final info = await DeviceInfoPlugin().androidInfo;
|
||||
if (info.version.sdkInt <= 24) {
|
||||
return retry.RetryClient(IOClient(customHttpClient(ISRG_X1)));
|
||||
}
|
||||
return retry.RetryClient(cronet.CronetClient.defaultCronetEngine());
|
||||
}
|
||||
if (PlatformInfos.isIOS || PlatformInfos.isMacOS) {
|
||||
return retry.RetryClient(
|
||||
cupertino_http.CupertinoClient.defaultSessionConfiguration(),
|
||||
);
|
||||
}
|
||||
|
||||
return retry.RetryClient(http.Client());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
|||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
flutter_vodozemac
|
||||
jni
|
||||
)
|
||||
|
||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||
|
|
|
|||
40
pubspec.lock
40
pubspec.lock
|
|
@ -254,6 +254,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.13.1"
|
||||
cronet_http:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: cronet_http
|
||||
sha256: df26af0de7c4eff46c53c190b5590e22457bfce6ea679aedb1e6326197f27d6f
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.4.0"
|
||||
cross_file:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -278,6 +286,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
cupertino_http:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: cupertino_http
|
||||
sha256: "8fb9e2c36d0732d9d96abd76683406b57e78a2514e27c962e0c603dbe6f2e3f8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -943,6 +959,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.1.2"
|
||||
http_profile:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_profile
|
||||
sha256: "7e679e355b09aaee2ab5010915c932cce3f2d1c11c3b2dc177891687014ffa78"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.0"
|
||||
image:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -1044,6 +1068,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
jni:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: jni
|
||||
sha256: d2c361082d554d4593c3012e26f6b188f902acd291330f13d6427641a92b3da1
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.14.2"
|
||||
js:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -1260,6 +1292,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
objective_c:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: objective_c
|
||||
sha256: "9f034ba1eeca53ddb339bc8f4813cb07336a849cd735559b60cdc068ecce2dc7"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.1.0"
|
||||
opus_caf_converter_dart:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ dependencies:
|
|||
blurhash_dart: ^1.2.1
|
||||
chewie: ^1.12.1
|
||||
collection: ^1.18.0
|
||||
cronet_http: ^1.4.0
|
||||
cross_file: ^0.3.4+2
|
||||
cupertino_http: ^2.2.0
|
||||
cupertino_icons: any
|
||||
desktop_drop: ^0.4.4
|
||||
desktop_notifications: ^0.6.3
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
|||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
flutter_local_notifications_windows
|
||||
flutter_vodozemac
|
||||
jni
|
||||
)
|
||||
|
||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue