1

going on Flutter documentation I found that fetching data was done, sometimes, by using http.Client and sometimes not (just http.get for example). So I was wondering the purpose of using http.Client.

These are the two sites where I found this:

https://flutter.io/cookbook/networking/fetch-data/

https://flutter.io/cookbook/networking/background-parsing/

Little Monkey
  • 5,395
  • 14
  • 45
  • 83

1 Answers1

4

The http package uses a default IOClient when you use the convenience http.get and http.post methods. However, sometimes you might want to use a specialized Client, for example to change the default HTTPS certificate validation. See this question.

In this circumstance, you can create any Client subclass and use it in the ways shown in your second link. It's rarely necessary, though so the syntax used in your first link is normally sufficient.

Richard Heap
  • 48,344
  • 9
  • 130
  • 112