In the previous part we created blank fragments. We can navigate between them using the navigation architecture component library. In this tutorial, we will add some actual functionality to this Forecast MVVM app, namely the ability to fetch weather from an API.

This means that in this part you are going to learn how to use Retrofit together with Gson to fetch and parse JSON data from an API. The API we are going to use is Apixu which is a weather API offering a generous free plan. You can apply what you learn here to any other API you desire so should there be any problems with Apixu in the future, you will be able to switch to a different API very easily.

?Get the code from this tutorial?


About the author 

Matt Rešetár

Matt is an app developer with a knack for teaching others. Working as a Flutter freelancer and most importantly developer educator, he doesn't have a lot of free time 😅 Yet he still manages to squeeze in tough workouts 💪

You may also like

Search Bar in Flutter – Logic & Material UI

Flutter Integration Test Tutorial + Firebase Test Lab & Codemagic

  • I followed your tutorial to the last, but i’m having a problem now when i run the app: java.lang.NullPointerException: Attempt to invoke virtual method ‘int’ on a null object reference
    what causes that?

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}