@@ -169,26 +169,54 @@ Prefer standalone widgets over helper methods for complex build methods.
169
169
- Use constants for test tags.
170
170
- No shared state between tests.
171
171
- Use random test ordering (` flutter test --test-randomize-ordering-seed random ` ).
172
+ - Include accessibility testing.
173
+
174
+ ## Code Commenting and Documentation
175
+
176
+ - Add documentation comments (///) to all public functions, classes, and significant code elements.
177
+ - Add inline comments (//) to explain any complex logic or non-obvious code blocks.
178
+
179
+ ## Accessibility
180
+
181
+ - Ensure the UI is accessible to users with disabilities.
182
+ - Provide sufficient color contrast and use readable font sizes.
183
+ - Adhere to accessibility guidelines, including semantic structure (` Semantics ` , ` MergeSemantics ` ).
184
+ - Implement proper focus management for keyboard users.
185
+ - Provide clear visual cues for the currently focused element.
172
186
173
187
## Theming
174
188
175
189
- Use ` ThemeData ` .
176
- - Access theme values with ` Theme.of(context) ` .
190
+ - Access theme values ** exclusively** with ` Theme.of(context) ` (e.g., ` Theme.of(context).primaryColor ` ). ** Do not introduce hardcoded color values.**
191
+ - Emphasize a minimalist approach, avoiding excessive use of colors and gradients.
192
+ - The UI must adapt to both light and dark themes.
177
193
- Typography:
178
194
- Import fonts, declare in ` pubspec.yaml ` .
179
195
- Use ` flutter_gen ` for type-safe access.
180
196
- Create custom text styles (` AppTextStyle ` ).
181
197
- Use ` TextTheme ` .
198
+ - Establish a clear visual hierarchy using font sizes, weights, line height, letter spacing, and text alignment. Optimize for readability.
182
199
- Colors:
183
200
- Create custom colors (` AppColors ` ).
184
- - Use ` ColorScheme ` .
201
+ - Use ` ColorScheme ` to define component colors, using theme-based colors.
202
+ - Use the ` accentColor ` sparingly for key interactive elements or important information.
185
203
- Use component themes (e.g., ` FilledButtonThemeData ` ).
186
204
- Define spacing constants (` AppSpacing ` ).
187
205
206
+ ## Localization
207
+
208
+ - All hardcoded text in the UI must be localized using the ` l10n ` feature.
209
+ - Reference the ` lib/l10n/ ` directory for localization files.
210
+ - UI code should only include localized variables, not hardcoded strings.
211
+
188
212
## Layouts
189
213
190
214
- Constraints flow down, sizes go up, parent sets position.
191
215
216
+ ### Whitespace
217
+
218
+ - Utilize whitespace (padding, margin, spacing) as a key design element to create visual balance, improve readability, and group related content.
219
+
192
220
### Rows and Columns
193
221
194
222
- ` Row ` : Horizontal layout.
@@ -213,4 +241,18 @@ Prefer standalone widgets over helper methods for complex build methods.
213
241
- ` shrinkWrap ` : ` ListView ` takes only needed space.
214
242
215
243
- ` SingleChildScrollView ` : Makes a single widget scrollable. Prefer ` ListView ` for lists.
244
+
245
+ ### Responsive and Adaptive Design
246
+
247
+ - Design the UI to be responsive and adapt to different screen sizes and orientations.
248
+ - Use ` LayoutBuilder ` to get the constraints of the current widget and build different UIs based on those constraints.
249
+ - Consider using ` TwoPane ` for large screens (e.g., tablets, foldables) to display two views side-by-side.
250
+ - Use ` AdaptiveGridView ` for creating grids that adapt to different screen sizes.
251
+ - Support both RTL (right-to-left) and LTR (left-to-right) layouts.
252
+ - Use the ` Directionality ` widget to specify the text direction.
253
+ - Use logical properties (e.g., ` EdgeInsetsDirectional ` instead of ` EdgeInsets.only(left:...) ` ).
254
+ - Prefer widgets that use ` start ` and ` end ` instead of ` left ` and ` right ` .
255
+ - Consider mirroring icons or images when appropriate.
256
+ - Ensure correct text alignment.
257
+
216
258
- Avoid using ` Expanded ` inside ` Wrap ` , ` ListView ` , and ` SingleChildScrollView ` unless the nested widget has a fixed size.
0 commit comments