File tree Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Original file line number Diff line number Diff line change 44
44
///
45
45
/// ```
46
46
/// void main() {
47
- /// var clientFactory = Client.new; // The default Client.
47
+ /// final Client httpClient;
48
48
/// if (Platform.isIOS || Platform.isMacOS) {
49
- /// clientFactory = CupertinoClient.defaultSessionConfiguration.call;
49
+ /// final config = URLSessionConfiguration.ephemeralSessionConfiguration()
50
+ /// ..cache = URLCache.withCapacity(memoryCapacity: 2 * 1024 * 1024)
51
+ /// ..httpAdditionalHeaders = {'User-Agent': 'Book Agent'};
52
+ /// httpClient = CupertinoClient.fromSessionConfiguration(config);
53
+ /// } else {
54
+ /// httpClient = IOClient(HttpClient()..userAgent = 'Book Agent');
50
55
/// }
51
- /// runWithClient(() => runApp(const MyFlutterApp()), clientFactory);
52
- /// }
53
- /// ```
54
56
///
55
- /// After the above setup, calling [Client] methods or any of the
56
- /// `package:http` convenient functions (e.g. [get] ) will result in
57
- /// [CupertinoClient] being used on macOS and iOS.
57
+ /// runApp(Provider<Client>(
58
+ /// create: (_) => httpClient,
59
+ /// child: const BookSearchApp(),
60
+ /// dispose: (_, client) => client.close()));
61
+ /// }
62
+ /// ```
58
63
///
59
64
/// # NSURLSession API
60
65
///
Original file line number Diff line number Diff line change 2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
- /// A [Client] implementation based on the
6
- /// [Foundation URL Loading System] (https://developer.apple.com/documentation/foundation/url_loading_system).
7
- library ;
8
-
9
5
import 'dart:async' ;
10
6
import 'dart:io' ;
11
7
import 'dart:typed_data' ;
You can’t perform that action at this time.
0 commit comments