A sample for beginners to get out of their architecture black box paradigm
Steps that I performed in the video
- Extracted
MyHomePageclass frommain.dartto a separate class namedusers_list_page.dart - Extracted out the http call from
UsersListProviderto a separate repository class (UsersRepository) - Extracted out widgets from
UsersListPageto awidgetsfolder so that the page file becomes a table of contents for the UI components - Injected
UsersRepositoryas a dependency. MadeUsersRepositoryas a required parameter forUsersListProvider's constructor. - Added
getItto register theUsersRepositoryclass
- Created three separate folders named as
ui,dataanddomain - Moved the provider file, ui file, and
widgetsfolder to theuifolder - Created an abstract class for
UsersRepositorywith once functiongetUser() - Renamed the previous
UsersRepositoryclass toRestApiUsersRepositoryand made it implement the abstract class we just created - Moved
UsersRepositoryabstract class todomain/repositoriesfolder - Moved
RestApiUsersRepositoryclass todatafolder - Refactored the
getItregistration to use the abstraction we just created - Created a new
MockUsersRepositoryclass to show how we can point our whole app from one database to another in a blink of an eye