15 lines
416 B
Dart
15 lines
416 B
Dart
import 'dart:io';
|
|
import 'package:http/http.dart' as http;
|
|
import 'package:http/io_client.dart';
|
|
|
|
class HttpClientFactory {
|
|
static http.Client createClient({bool allowSelfSigned = false}) {
|
|
if (allowSelfSigned) {
|
|
final ioClient = HttpClient()
|
|
..badCertificateCallback = (X509Certificate cert, String host, int port) => true;
|
|
return IOClient(ioClient);
|
|
}
|
|
return http.Client();
|
|
}
|
|
}
|