diff --git a/pkgs/flutter_http_example/lib/main.dart b/pkgs/flutter_http_example/lib/main.dart index 548c3dee0a..afe8363029 100644 --- a/pkgs/flutter_http_example/lib/main.dart +++ b/pkgs/flutter_http_example/lib/main.dart @@ -15,6 +15,14 @@ import 'http_client_factory.dart' void main() { runApp(Provider( + // `Provider` calls its `create` argument once when a `Client` is + // first requested (through `BuildContext.read()`) and uses that + // same instance for all future requests. + // + // Reusing the same `Client` may: + // - reduce memory usage + // - allow caching of fetched URLs + // - allow connections to be persisted create: (_) => http_factory.httpClient(), child: const BookSearchApp(), dispose: (_, client) => client.close()));