Search code examples
flutterretrofitflutter-dependencies

using http package in flutter for networking APIs is a good practice OR its better to use Retrofit, chopper or dio?


Actually I want to know which package is more beneficial from the user perspective, if there are other advantage pls let know in the comments. THANK YOU


Solution

  • From the user's (consumer's) perspective, http/dio/etc doesn't matter at all.

    From a developer's perspective (my experience), it has been easier to handle exceptions with the dio package than using http. I had a lot of frustration trying to catch HTTP Response 500 when I was using http, and my app keeps on crashing even though my code had a try/catch. Trying to add timeouts in my http code has been especially difficult. But with dio, they have a built-in solution (connectTimeout).

    Also in general, writing networking code with dio (I haven't tried Chopper or Retrofit) is faster and easier than writing code using http.