@@ -249,15 +249,22 @@ void main() {
249
249
}
250
250
```
251
251
252
- In Flutter, you can use a one of many
252
+ When using the Flutter SDK , you can use a one of many
253
253
[ state management approaches] [ flutterstatemanagement ] .
254
254
255
- If you depend on code that uses top-level functions (e.g. ` http.post ` ) or
256
- calls the [ ` Client() ` ] [ clientconstructor ] constructor, then you can use
257
- [ ` runWithClient ` ] [ runwithclient ] to ensure that the correct
258
- ` Client ` is used. When an [ Isolate] [ isolate ] is spawned, it does not inherit
259
- any variables from the calling Zone, so ` runWithClient ` needs to be used in
260
- each Isolate that uses ` package:http ` .
255
+ > [ !TIP]
256
+ > [ The Flutter HTTP example application] [ flutterhttpexample ] demonstrates
257
+ > how to make the configured [ ` Client ` ] [ client ] available using
258
+ > [ ` package:provider ` ] [ provider ] and
259
+ > [ ` package:http_image_provider ` ] [ http_image_provider ] .
260
+
261
+ When using the Dart SDK, you can use [ ` runWithClient ` ] [ runwithclient ] to
262
+ ensure that the correct [ ` Client ` ] [ client ] is used when explicit argument
263
+ passing is not an option. For example, if you depend on code that uses
264
+ top-level functions (e.g. ` http.post ` ) or calls the
265
+ [ ` Client() ` ] [ clientconstructor ] constructor. When an [ Isolate] [ isolate ] is
266
+ spawned, it does not inherit any variables from the calling Zone, so
267
+ ` runWithClient ` needs to be used in each Isolate that uses ` package:http ` .
261
268
262
269
You can ensure that only the ` Client ` that you have explicitly configured is
263
270
used by defining ` no_default_http_client=true ` in the environment. This will
@@ -269,11 +276,6 @@ $ flutter build appbundle --dart-define=no_default_http_client=true ...
269
276
$ dart compile exe --define=no_default_http_client=true ...
270
277
```
271
278
272
- > [ !TIP]
273
- > [ The Flutter HTTP example application] [ flutterhttpexample ] demonstrates
274
- > how to make the configured [ ` Client ` ] [ client ] available using
275
- > [ ` package:provider ` ] [ provider ] and [ ` package:http_image_provider ` ] [ http_image_provider ] .
276
-
277
279
[ browserclient ] : https://pub.dev/documentation/http/latest/browser_client/BrowserClient-class.html
278
280
[ client ] : https://pub.dev/documentation/http/latest/http/Client-class.html
279
281
[ clientconstructor ] : https://pub.dev/documentation/http/latest/http/Client/Client.html
0 commit comments