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: docs/resources/style-guide.md
+24-3Lines changed: 24 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,14 +25,17 @@ Various naming styles (as suggested by [Dart Effective Style Guide](https://dart
25
25
26
26
### Components and Widgets
27
27
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
+
28
30
:::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`.
30
32
31
33
-**Suffix Widget Names with the Type of Widget:** When naming widgets, include a suffix that indicates the type of widget. Example: `LoginButtonWidget`, `ProfileCardComponent`, `HeaderViewWidget`.
32
34
33
35
-**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).
34
36
:::
35
37
38
+
36
39
:::danger[Don'ts]
37
40
-**Don’t Use Prefixes Unnecessarily:** Avoid adding prefixes that do not enhance clarity or that are redundant. Bad Example: `MyAppButtonWidget` (if `ButtonWidget` would suffice).
38
41
@@ -43,8 +46,10 @@ Various naming styles (as suggested by [Dart Effective Style Guide](https://dart
43
46
44
47
### Pages & Screens
45
48
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
+
46
51
:::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`.
48
53
49
54
-**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`.
50
55
@@ -56,5 +61,21 @@ Various naming styles (as suggested by [Dart Effective Style Guide](https://dart
56
61
57
62
-**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`.
58
63
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`.
60
75
:::
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