A sample for beginners to get out of their architecture black box paradigm
Steps that I performed in the video
- Extracted
MyHomePage
class frommain.dart
to a separate class namedusers_list_page.dart
- Extracted out the http call from
UsersListProvider
to a separate repository class (UsersRepository
) - Extracted out widgets from
UsersListPage
to awidgets
folder so that the page file becomes a table of contents for the UI components - Injected
UsersRepository
as a dependency. MadeUsersRepository
as a required parameter forUsersListProvider
's constructor. - Added
getIt
to register theUsersRepository
class
- Created three separate folders named as
ui
,data
anddomain
- Moved the provider file, ui file, and
widgets
folder to theui
folder - Created an abstract class for
UsersRepository
with once functiongetUser()
- Renamed the previous
UsersRepository
class toRestApiUsersRepository
and made it implement the abstract class we just created - Moved
UsersRepository
abstract class todomain/repositories
folder - Moved
RestApiUsersRepository
class todata
folder - Refactored the
getIt
registration to use the abstraction we just created - Created a new
MockUsersRepository
class to show how we can point our whole app from one database to another in a blink of an eye