Load data from api to recylerview using JetPack Compose

Hi today we look in to an concept of how to load data from an api using retrofit and load in to an recylerview using Jetpack Compose and single selection highlight on recylerview selection.

First we import things needed for retrofit in to our app level build gradle

We are going to create a model data class of name Movie.kt with the following variables like name,category etc

Now lets create an interface class ApiService.kt to get and return data to viewmodel

Next we are going to create ApiViewModel.kt we are launching our api call inside viewModelScope.launch so it will run as long as our viewmodel active on any failure we will be passing to our error message part.

Now comes the ui part you can see we created a item for display MovieItem function

Thats it we have our APi loaded to the recylerview.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store