Skip to content

Commit

Permalink
Update http_client_factory.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
brianquinlan committed Jan 4, 2024
1 parent 10a7630 commit 8516a9e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkgs/flutter_http_example/lib/http_client_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ import 'package:cupertino_http/cupertino_http.dart';
import 'package:http/http.dart';
import 'package:http/io_client.dart';

const maxCacheSize = 2 * 1024 * 1024;
const _maxCacheSize = 2 * 1024 * 1024;

Client httpClient() {
if (Platform.isAndroid) {
final engine = CronetEngine.build(
cacheMode: CacheMode.memory,
cacheMaxSize: maxCacheSize,
cacheMaxSize: _maxCacheSize,
userAgent: 'Book Agent');
return CronetClient.fromCronetEngine(engine);
}
if (Platform.isIOS || Platform.isMacOS) {
final config = URLSessionConfiguration.ephemeralSessionConfiguration()
..cache = URLCache.withCapacity(memoryCapacity: maxCacheSize)
..cache = URLCache.withCapacity(memoryCapacity: _maxCacheSize)
..httpAdditionalHeaders = {'User-Agent': 'Book Agent'};
return CupertinoClient.fromSessionConfiguration(config);
}
Expand Down

0 comments on commit 8516a9e

Please sign in to comment.