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
-**Be Consistent:** Whatever conventions you choose, apply them consistently across the project.
21
27
-**Be Descriptive:** Names should be self-explanatory, reducing the need for additional comments to explain what a variable, function, or class does.
22
28
-**Avoid Abbreviations:** Unless it's a well-known abbreviation, spell out words to avoid confusion.
23
29
24
30
25
31
26
-
### Components and Widgets
32
+
### Pages & Components
33
+
Use **UpperCamelCase** for all widget, component, page, and screen names to maintain consistency and readability. FlutterFlow ensures clarity by automatically adding "Widget" to widget names when generating code. For components, you can suffix the name with "Component" to clearly distinguish them.
27
34
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.
35
+
Similarly, for pages and screens, include "Page" or "Screen" in the name to indicate their purpose.This approach aligns with Dart conventions for class names and ensures a well-organized project structure.
29
36
30
37
:::tip[Do's]
31
-
-**Use UpperCamelCase for Widget Names:** Always write widgets and component names in UpperCamelCase. Example: `MyCustomButton`, `UserProfileWidget`, `MainViewComponent`.
38
+
-**Use UpperCamelCase for Names:** Always use **UpperCamelCase** for widgets, components, pages, and screens. Examples: `CustomButton`, `UserProfilePage`, `MainViewComponent`.
32
39
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`.
40
+
-**Include "Screen" or "Page" in Page Names:**Use "Screen" or "Page" in file names to identify UI screens or pages. Examples: `LoginScreen`, `SettingsPage`.
34
41
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).
36
-
:::
42
+
-**Use Prefixes for Clarity When Necessary:** Add a prefix if it significantly improves clarity or prevents naming conflicts. Example: `AdminUserProfile` (to differentiate it from `CustomerUserProfile` or `UserProfile`).
37
43
44
+
-**Be Descriptive and Clear in File Names:** Ensure names are descriptive enough to convey their purpose at a glance. Examples: `OrderConfirmationScreen`, `ProductDetailsPage`.
45
+
:::
38
46
39
47
:::danger[Don'ts]
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).
48
+
-**Don’t Use Unnecessary Prefixes:** Avoid prefixes that do not add clarity or are redundant. Bad Example: `AppPrimaryButton` (if `PrimaryButton` is sufficient).
41
49
42
-
-**Don’t Use LowerCamelCase for Class Names:** Avoid using **lowerCamelCase** for class names, which is generally reserved for variables and method names. Bad Example: `loginButtonWidget`, `userProfileComponent`.
50
+
-**Don’t Add "Widget" Explicitly:** Avoid adding "Widget" to class or component names manually, as FlutterFlow already appends it during code generation. Bad Examples: `ButtonWidget`, `ProfileCardWidget`.
51
+
52
+
-**Don’t Use LowerCamelCase for Class Names:** Reserve **lowerCamelCase** for variables and methods, not for components, or pages. Bad Examples: `loginButton`, `userProfile`.
53
+
54
+
-**Don’t Mix Naming Conventions:** Maintain consistency with UpperCamelCase for all widgets, components, pages, and screens. Bad Examples: `userLogin`, `Profilecard`, `headerView`.
55
+
56
+
-**Don’t Use Generic Names Without Purpose:** Avoid overly generic names that do not clearly convey the file’s intent. Bad Examples: `Main`, `View`, `Screen1`.
43
57
44
-
-**Don’t Mix Naming Conventions:** Stick to **UpperCamelCase** consistently for all class names and widgets. Mixing conventions can reduce code readability. Bad Example: `userLoginWidget`, `ProfilecardComponent`, `headerView`.
45
58
:::
46
59
47
-
### Pages & Screens
60
+
### Custom Data Types & Enums
48
61
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.
62
+
When naming custom data types and enums, use UpperCamelCase for consistency and clarity. Ensure that names are descriptive, providing a clear representation of the entity or purpose.
50
63
51
64
:::tip[Do's]
52
-
-**Use UpperCamelCase for Page Names:** Name your Pages using UpperCamelCase to clearly indicate their purpose. Example: `HomePage`, `SearchResultsScreen`, `UserProfilePage`.
53
65
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`.
66
+
-**Use UpperCamelCase for Custom Data Types:** Name your custom data types using **UpperCamelCase**. Ensure that names are clear, concise, and descriptive, reflecting the entity they represent. Good Examples: `UserModel`, `ProductDetails`, `OrderItem`.
67
+
68
+
-**Use consistent naming for Enum Names and Values:** Use **UpperCamelCase** for the enum name such as `Status`, `ConnectionState`, `UserRole` and **lowerCamelCase** for its values for e.g `{active, inactive, pending}`. This approach aligns with Dart's enum naming guidelines and ensures consistency.
55
69
56
-
-**Be Descriptive and Clear in File Names:**Ensure that file names are descriptive enough to convey their purpose or content at a glance. Example: `OrderConfirmationScreen`, `ProductDetailsPage`.
70
+
-**Use Plural Names for Lists:**If the data type represents a List, use a plural name to clarify its purpose. Good Example: `OrderItems` (to represent multiple `OrderItem` objects).
57
71
:::
58
72
59
73
:::danger[Don'ts]
60
-
-**Don’t Use All Lowercase or Mixed Case in Page Names:** Avoid using all lowercase or inconsistent casing in file names, as it can lead to confusion and reduce readability. Bad Example: `homepage`, `searchResultscreen`.
61
74
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`.
75
+
-**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`.
63
76
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
-
:::
77
+
-**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`.
66
78
79
+
-**Don’t Mix Naming Conventions for Enums:** Maintain consistent capitalization between enum names and their values. Bad Example: `enum UserRole { Admin, EDITOR, viewer }`
80
+
:::
67
81
68
-
### Custom Data Types
82
+
### Constants
69
83
70
-
When naming data types, use **UpperCamelCase**for consistency and opt for descriptive names that clearly represent the entity.
84
+
Flutter prefers using a lowercase `k` prefix for constants to indicate their immutability, especially for project-specific constants. This approach is more concise and aligns with Dart's common practices. Use **SCREAMING_SNAKE_CASE**only when contributing to global or legacy projects where it is already in use.
71
85
72
86
:::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`.
87
+
-**Start Constants with a k Prefix:** Always use a lowercase `k` followed by **UpperCamelCase** for constants in FlutterFlow projects.
88
+
-**Use Descriptive and Contextual Names:** Clearly describe the purpose of the constant. Avoid using abbreviations unless they are widely understood. Examples: `kUserRoleAdmin`, `kMaxUploadSizeMb`
75
89
:::
76
90
77
91
:::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`.
92
+
-**Don’t Omit the k Prefix for Constants:** Avoid using plain names for constants in a Flutter-specific project, as they might conflict with variables or methods. Bad Examples: `maxItems`, `apiEndpoint`.
93
+
-**Don’t Use Vague or Generic Names:** Avoid using names that fail to describe the purpose of the constant. Bad Examples: `VALUE`, `DATA`, `X`, `Y`.
0 commit comments