You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: memory-bank/systemPatterns.md
+33-21Lines changed: 33 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,19 +59,10 @@ my_feature/
59
59
feature_state.dart
60
60
view/
61
61
feature_page.dart
62
-
feature_view.dart
63
-
view.dart
64
62
my_feature.dart
65
63
```
66
64
67
-
The `view.dart` barrel file would contain:
68
-
69
-
```dart
70
-
export 'feature_page.dart';
71
-
export 'feature_view.dart';
72
-
```
73
-
74
-
**Caution:** Not all files should be exported. Files used internally within the same folder, but not intended for public use, should not be in the barrel file.
65
+
**Caution:** Not all files should be exported. Files used internally within the same folder, but not intended for public use, should not be in the barrel file. In the structure above, `feature_page.dart` already includes the view, so a separate `view.dart` barrel file is not needed.
75
66
76
67
By convention, BLoCs are typically broken into separate files for events, states, and the BLoC itself:
77
68
@@ -100,7 +91,6 @@ my_app/
100
91
login_state.dart
101
92
view/
102
93
login_page.dart
103
-
view.dart
104
94
test/
105
95
login/
106
96
bloc/
@@ -111,7 +101,7 @@ my_app/
111
101
login_page_test.dart
112
102
```
113
103
114
-
Each layer abstracts the underlying layers' implementation details. Avoid indirect dependencies. The Repository Layer shouldn't know *how* the Data Layer fetches data, and the Presentation Layer shouldn't directly access values from Shared Preferences. Implementation details should not leak between layers.
104
+
Each layer abstracts the underlying layers’ implementation details. Avoid indirect dependencies. The Repository Layer shouldn't know *how* the Data Layer fetches data, and the Presentation Layer shouldn't directly access values from Shared Preferences. Implementation details should not leak between layers. The `view` folder contains the combined Page/View file (e.g., `login_page.dart`), and the `bloc` folder contains the BLoC-related files.
115
105
116
106
Data should flow from the bottom up, and a layer can only access the layer directly beneath it. The `LoginPage` should never directly access the `ApiClient`, and the `ApiClient` should not depend on the `UserRepository`. This ensures each layer has a specific responsibility and can be tested in isolation.
117
107
@@ -430,24 +420,27 @@ if (email.isValid) {
430
420
431
421
## Page/View Pattern
432
422
433
-
Each feature typically has a "page" widget and a "view" widget. This promotes separation of concerns, testability, and maintainability.
423
+
Each feature combines the "page" and "view" widgets into a single file. This promotes separation of concerns and testability while reducing file count.
434
424
435
425
-**Page Widget** (e.g., `HeadlinesFeedPage`): A `StatelessWidget` responsible for:
436
426
- Providing necessary BLoCs and repositories using `BlocProvider` or `MultiBlocProvider`.
437
427
- Adding initial events to the BLoC (e.g., fetching initial data).
438
428
- Defining the route for the page.
439
-
- Gathering dependencies from the context (e.g., using `context.read`).
440
-
- Providing these dependencies to the `View` (typically via a `BlocProvider`).
441
429
442
-
-**View Widget** (e.g., `_HeadlinesFeedView`): A `StatelessWidget` responsible for:
430
+
-**View Widget** (e.g., `_HeadlinesFeedView`): A private `StatelessWidget` within the same file, responsible for:
443
431
- Building the UI based on the current state of the BLoC.
444
432
- Handling user interactions and dispatching events to the BLoC.
0 commit comments