Issue
I am trying to refactor my Flutter weather application.
It eventually calls an API to provide weather data based with a location as a parameter.
Currently, I have :
- A WeatherJSONModel.dart which corresponds to the JSON response given by the API I use.
- A WeatherAPI.dart files which manages to call the API with the parameters, and parse the JSON response into a the above model.
- A WeatherModel.dart which is the model for the data displayed by the app.
- A WeatherProvider (extends ChangeNotifier) which converts the WeatherJSONModel returned by the API into a WeatherModel then made available for the app.
I very much doubt this the most efficient way to do it, but can’t find how to properly implement my calls.
Should it be more APICallClass into ResponseHandlerClass into ProviderClass ?
Thank you !
TLDR; How to implement API calls and JSON parsing following SOLID principles ?
Solution
One of the best tutorials on this topic in flutter (in my opinion) can be found here:
https://github.com/ResoCoder/flutter-tdd-clean-architecture-course
There is also a written series and a 7 hour YouTube Tutorial of this:
Here is the architectur proposal:
Answered By – DennisSzymanski
Answer Checked By – Robin (FlutterFixes Admin)