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/

1
  • It's there for tests purposes Commented Sep 9, 2018 at 9:09

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.