Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkgs/flutter_http_example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ import 'http_client_factory.dart'

void main() {
runApp(Provider<Client>(
// `Provider` calls its `create` argument once when a `Client` is
// first requested (through `BuildContext.read<Client>()`) 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()));
Expand Down