Skip to content

Commit

Permalink
Update main.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
brianquinlan committed Nov 2, 2023
1 parent 3662564 commit aa22608
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkgs/flutter_http_example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ import 'http_client_factory.dart'
if (dart.library.html) 'http_client_factory_web.dart' as http_factory;

void main() {
// Some plugins may offer a way to inject a `package:http` `Client` so
// use `runWithClient` to control the `Client` that they use.
// `runWithClient` is used to control which `package:http` `Client` is used
// when the `Client` constructor is called. This method allows you to choose
// the `Client` even when the package that you are using does not offer
// explicit parameterization.
//
// `runWithClient` is not sufficient, however, because flutter tests do
// not preserve the `Zone` used as part of the `runWithClient`
// implementation. See https://github.com/flutter/flutter/issues/96939.
// However, `runWithClient` does not work with Flutter tests. See
// https://github.com/flutter/flutter/issues/96939.
//
// Use `package:provider` and `runWithClient` together so that tests and
// unparameterized `Client` usages both work.
runWithClient(
() => runApp(Provider<Client>(
create: (_) => http_factory.httpClient(),
Expand Down

0 comments on commit aa22608

Please sign in to comment.