-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Ehsan Rashidi edited this page Oct 27, 2025
·
1 revision
ECS (Event Component System) is a modular state management system for Flutter.
It provides a structured approach to separate data, behavior, and logic in your app.
The system is built around these core concepts:
- Entities – Objects or state holders in the system.
- Components – Data containers attached to entities.
- Systems – Logic units that process entities and components.
- Features – Groups of entities and systems to organize your app.
- Manager – The central coordinator that handles features, systems, and entities.
ECS supports:
- Reactive updates – Widgets automatically rebuild when entity state changes.
- Lifecycle management – Systems can initialize, execute, clean up, and teardown.
-
UI integration – Widgets can access ECS state via
ECSContextandECSWidget.
-
Separation of Concerns
- Data (Components) is separated from logic (Systems) and UI (Widgets).
-
Reactive Programming
- Changes to entities automatically notify systems and UI components.
-
Modular Architecture
- Features allow grouping related entities and systems for easier maintenance.
-
Global State Management
-
ECSManagerprovides a centralized way to access entities across the app.
-
-
Lifecycle Control
- Systems can perform setup (
InitializeSystem), periodic updates (ExecuteSystem), cleanup (CleanupSystem), and teardown (TeardownSystem).
- Systems can perform setup (
- ECSManager: Root of the ECS system; coordinates features and entities.
- ECSFeature: Groups related entities and systems.
- ECSEntity / ECSComponent: Data objects that hold state.
- ECSSystem: Logic that processes entities or reacts to changes.
- ECSLogger: Provides logging and debugging support.
- Organize your app into features for logical separation.
- Use reactive systems for automatic reactions to entity changes.
- Wrap your widget tree with
ECSScopefor UI integration. - Access entities in widgets using
ECSContext.watchorECSContext.get.