Skip to content

Commit 4caa18b

Browse files
committed
Add custom data types style guide.
1 parent ad1d93e commit 4caa18b

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

docs/resources/style-guide.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ Various naming styles (as suggested by [Dart Effective Style Guide](https://dart
2525

2626
### Components and Widgets
2727

28+
Use UpperCamelCase for all widget and component names to maintain consistency and readability. Always suffix widget names with their type (e.g., "Widget" or "Component") to clearly indicate their purpose.This aligns with Dart conventions for class names.
29+
2830
:::tip[Do's]
29-
- **Use UpperCamelCase for Class Names:** Always write class names, including widgets and components, in UpperCamelCase. Example: `MyCustomButton`, `UserProfileWidget`, `MainViewComponent`.
31+
- **Use UpperCamelCase for Widget Names:** Always write widgets and component names in UpperCamelCase. Example: `MyCustomButton`, `UserProfileWidget`, `MainViewComponent`.
3032

3133
- **Suffix Widget Names with the Type of Widget:** When naming widgets, include a suffix that indicates the type of widget. Example: `LoginButtonWidget`, `ProfileCardComponent`, `HeaderViewWidget`.
3234

3335
- **Use Prefixes for Clarity When Necessary:** Add a prefix only if it significantly improves clarity or helps avoid naming conflicts. Example: `AppUserProfileWidget` (if `UserProfileWidget` is already in use).
3436
:::
3537

38+
3639
:::danger[Don'ts]
3740
- **Don’t Use Prefixes Unnecessarily:** Avoid adding prefixes that do not enhance clarity or that are redundant. Bad Example: `MyAppButtonWidget` (if `ButtonWidget` would suffice).
3841

@@ -43,8 +46,10 @@ Various naming styles (as suggested by [Dart Effective Style Guide](https://dart
4346

4447
### Pages & Screens
4548

49+
Use **UpperCamelCase** for page and screen file names with "Screen" or "Page" in the name to ensure clarity and consistency. This helps developers quickly identify and distinguish UI elements, improving project organization and readability.
50+
4651
:::tip[Do's]
47-
- **Use CamelCase for Page Names:** Name your Pages using CamelCase to clearly indicate their purpose. Example: `HomePage`, `SearchResultsScreen`, `UserProfilePage`.
52+
- **Use UpperCamelCase for Page Names:** Name your Pages using UpperCamelCase to clearly indicate their purpose. Example: `HomePage`, `SearchResultsScreen`, `UserProfilePage`.
4853

4954
- **Include "Screen" or "Page" in the Page Name:** Always include the word "Screen" or "Page" in the file name to clearly identify UI screens or pages. Example: `LoginScreen`, `SettingsPage`.
5055

@@ -56,5 +61,21 @@ Various naming styles (as suggested by [Dart Effective Style Guide](https://dart
5661

5762
- **Don’t Use Generic Names Without Purpose:** Avoid generic names that do not clearly indicate the file’s purpose or content. Bad Example: `Main`, `View`, `Screen1`.
5863

59-
- **Don’t Mix Naming Conventions:** Consistently use CamelCase for all page names related to pages and screens. Mixing conventions can make your project harder to navigate. Bad Example: `search_results_screen`, `Userprofilepage`.
64+
- **Don’t Mix Naming Conventions:** Consistently use UpperCamelCase for all page names related to pages and screens. Mixing conventions can make your project harder to navigate. Bad Example: `search_results_screen`, `Userprofilepage`.
65+
:::
66+
67+
68+
### Custom Data Types
69+
70+
When naming data types, use **UpperCamelCase** for consistency and opt for descriptive names that clearly represent the entity.
71+
72+
:::tip[Do's]
73+
74+
- Use UpperCamelCase for Custom Data Types: Name custom data types using UpperCamelCase and ensure that the class names are clear and descriptive, accurately reflecting the entity they represent Example: `UserModel`, `ProductDetails`, `OrderItem`.
6075
:::
76+
77+
:::danger[Don'ts]
78+
79+
- **Don’t Use All Lowercase or Mixed Case for Custom Data Types:** Avoid using all lowercase or inconsistent casing in data model class names, as it reduces readability. Bad Example: `usermodel`, `product_details`.
80+
81+
- **Don’t Use Vague or Non-Descriptive Names**: Avoid using generic or unclear names that do not clearly describe the data entity. Bad Example: `DataModel`, `Entity`, `Item`.

0 commit comments

Comments
 (0)