How can I setup a framework for API calling in flutter ?
Instead of just creating a api call function need to create a framework that can be used for multiple future projects
How can I setup a framework for API calling in flutter ?
Instead of just creating a api call function need to create a framework that can be used for multiple future projects
3
Answers
If you are using Dio or any other libraries then the best way is to make a Dio helper class where you can change only the BASE_URL and will be globally used in all other classes after step by step you can add the not changeable things there.
I hope it helps
You can make a separate project for API calls and models, this project will include the model classes and services for API calls. For API calls you can use retrofit or dio, whatever you want to use. This project will not include the UI, make the project by following command.
Now you can include this framework project in many projects you want. Just add the path of this project in
pubspec.yaml
as followingNow you will be able to call the API functions.
I hope it helps.
you can try this.