From 37d536db8bf0909720b25385583b839861d39098 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Thu, 11 Jul 2024 15:19:47 -0700 Subject: [PATCH] Remove `runWithClient` Flutter example --- pkgs/cupertino_http/lib/cupertino_http.dart | 21 ++++++++++++------- .../lib/src/cupertino_client.dart | 4 ---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/pkgs/cupertino_http/lib/cupertino_http.dart b/pkgs/cupertino_http/lib/cupertino_http.dart index 8009d786cc..b85a868b4e 100644 --- a/pkgs/cupertino_http/lib/cupertino_http.dart +++ b/pkgs/cupertino_http/lib/cupertino_http.dart @@ -44,17 +44,22 @@ /// /// ``` /// void main() { -/// var clientFactory = Client.new; // The default Client. +/// final Client httpClient; /// if (Platform.isIOS || Platform.isMacOS) { -/// clientFactory = CupertinoClient.defaultSessionConfiguration.call; +/// final config = URLSessionConfiguration.ephemeralSessionConfiguration() +/// ..cache = URLCache.withCapacity(memoryCapacity: 2 * 1024 * 1024) +/// ..httpAdditionalHeaders = {'User-Agent': 'Book Agent'}; +/// httpClient = CupertinoClient.fromSessionConfiguration(config); +/// } else { +/// httpClient = IOClient(HttpClient()..userAgent = 'Book Agent'); /// } -/// runWithClient(() => runApp(const MyFlutterApp()), clientFactory); -/// } -/// ``` /// -/// After the above setup, calling [Client] methods or any of the -/// `package:http` convenient functions (e.g. [get]) will result in -/// [CupertinoClient] being used on macOS and iOS. +/// runApp(Provider( +/// create: (_) => httpClient, +/// child: const BookSearchApp(), +/// dispose: (_, client) => client.close())); +/// } +/// ``` /// /// # NSURLSession API /// diff --git a/pkgs/cupertino_http/lib/src/cupertino_client.dart b/pkgs/cupertino_http/lib/src/cupertino_client.dart index a525773316..eefa1189f0 100644 --- a/pkgs/cupertino_http/lib/src/cupertino_client.dart +++ b/pkgs/cupertino_http/lib/src/cupertino_client.dart @@ -2,10 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -/// A [Client] implementation based on the -/// [Foundation URL Loading System](https://developer.apple.com/documentation/foundation/url_loading_system). -library; - import 'dart:async'; import 'dart:io'; import 'dart:typed_data';