I want to create a common API class so I can call that API class for every API and get data.
I have tried but failed to get common response from API class. So now I am here to get some help from my stackoverflow team.
Thank you in advance
I want to create a common API class so I can call that API class for every API and get data.
I have tried but failed to get common response from API class. So now I am here to get some help from my stackoverflow team.
Thank you in advance
2
Answers
Create a file called
api_service.dart
.Inside
api_service.dart
, import the necessary packages:Create a class called ApiService that will contain the common API methods:
Below is full
api_service.dart
code:How to use: