Up until now we’ve created a Retrofit service to communicate with the weather API, we also created all of the pieces needed for a local database using the Room library. So, we basically have all of the data components of our app implemented, right? We can fetch data and then cache it locally, so all that’s left to do is to put it all in a repository to somehow centralize network and local data calls.

Well, while we’re really close to creating a repository, we still have one important step unfinished. We need to wrap the retrofit weather API service into a special class to create an abstraction and to give the code making network calls a better structure.

?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 💪 and guitar 🎸

You may also like

Flutter Custom & Staggered Page Transition Animation Tutorial

Flutter Firebase & DDD Course [5] – Sign-In Form Logic

  • what’s the name of the theme that you are using in the android studio?!
    I’ve searched and installed many material themes for that, but none of them was like the one that you are using! 😀

    Reply

  • what is alternative of getActiveNetworkInfo method because it shows deprecated in java i stuck on this i tried to find solution but not getting any proper answer, Btw your tutorials are Awesome!

    Here i’m using:
    android Studio version -> 3.4.1
    kotlin plugin version -> 1.3.40
    compileSdkVersion -> 29
    minSdkVersion -> 21
    targetSdkVersion -> 29

    Reply

  • Hi,
    In this tutorial how would you be able to handle network call callbacks like for events when there is a success call, onerrors (httperror), any throwable failures.
    What you did was handle the no network error in the DataSourceImpl, and only use Log.e

    But developers will need to get a handle on that event and do UI changes, for ex. showing error messages.

    For the success calls, I guess it will trigger the observer and pass the LiveData
    But how do you handle the different error scenarios?

    Thanks

    Reply

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