-
Notifications
You must be signed in to change notification settings - Fork 2
Architecture ‐ Contribution Guide
The BloC (Business Logic Component) architecture in Flutter is designed to separate the presentation layer from the business logic, ensuring a clean and maintainable codebase. Here's an overview of the roles of various components within this architecture:
Views are the UI components that render the application's visual elements. They are typically stateless and rely on BLoCs to manage their state.
-
Example:
HomeView
displays the user interface for the home page.
Components are reusable UI elements that can be embedded within views. They might include buttons, input fields, or custom widgets.
-
Example:
ScannerWidget
is a component used in theHomeView
.
Screens or pages represent a complete screen of content, which is usually composed of multiple views and components.
-
Example:
BottomNavigationView
manages the navigation between different screens.
BLoCs handle the business logic of the application. They receive events from the UI, process them, and update the UI by emitting new states.
-
Example:
HomeBloc
handles events related to the home page, such as QR code scanning.
Interactors folder contains BLoCs and events
Events are inputs to a BLoC that trigger it to perform some logic and emit a new state. They represent user interactions or lifecycle events.
-
Example:
_OnQRCodeScanned
inHomeBloc
is an event triggered when a QR code is scanned.
States are outputs of a BLoC that represent parts of the UI. States are emitted by BLoCs in response to events and trigger UI updates.
-
Example:
HomeState
represents the state of the home page UI.
Use cases encapsulate specific business rules or processes. They are often called by interactors to perform actions that reflect the application's core functionality.
-
Example:
GetUserTokensUseCase
retrieves the tokens associated with a user.
This architecture helps in maintaining a clean separation of concerns, making the code easier to manage and scale. Each component has a well-defined role, ensuring that the application remains modular and testable.