π FlutterFlow Best Practices Cheat Sheet
π 1. Project Organization
1.1 Folder Structure
/lib
βββ π pages
β βββ π home_page.dart
β βββ π login_page.dart
βββ π widgets
β βββ π custom_button.dart
βββ π backend
β βββ π collections
β βββ π€ user_collection.dart
βββ π custom_code
β βββ π οΈ custom_functions.dart
βββ π constants
βββ π¨ colors.dart
βββ π strings.dart
1.2 Example Page Structure
/pages
βββ π auth
β βββ π± auth_phone.dart
β βββ β
auth_verify.dart
β βββ β³ loading_screen.dart
β βββ π splash_screen.dart
βββ π business
β βββ π business_overview.dart
β βββ π business_details.dart
βββ π client
β βββ ποΈ client_category_browse.dart
β βββ π client_home.dart
βββ π onboarding
β βββ πΆ onboarding_step2.dart
β βββ β° setup_business_hours.dart
βββ π professionals
βββ π
professional_appointments.dart
βββ π professional_home.dart
βββ π professional_reports.dart
π·οΈ 2. Naming Conventions
2.1 Page Naming
- π Descriptive Names:
login_page.dart, profile_page.dart
- π« Avoid Numbers: Use
business_overview.dart instead of BusinessPage1
- π‘ Lowercase with Underscores:
product_details_page.dart
- π Class Names (Custom Widgets):
CustomButton, ProfileAvatar
- π‘ File Names:
custom_button.dart, profile_avatar.dart
- πͺ Variable Names:
submitButton, profileAvatar
π₯ 3. Firestore Best Practices
3.1 Naming Conventions for Firestore Fields
| Category | Convention | Example |
|---|
| π€ General Fields | camelCase | firstName, emailAddress |
| π ID Fields | Specific prefix/suffix | userId, orderId |
| β° Timestamp Fields | Specific names | createdAt, updatedAt |
| π€ User Reference Fields | Specific names | createdBy, updatedBy |
3.2 Lists and References
| Type | Convention | Example |
|---|
| π Lists of Items | Plural camelCase | tags, categories |
| π Document References | Singular with Ref suffix | userRef, postRef |
| π’ Lists of Related IDs | Plural with Ids suffix | userIds, productIds |
3.3 Nested Data Types
| Type | Convention | Example |
|---|
| πΊοΈ Maps (Objects) | Singular, optional Map suffix | addressMap, settingsMap |
| π Arrays of Maps | Plural, optional List/Maps/Array suffix | addresses, settingsList |
3.4 Example Firestore Schema
{
"userId": "abc123",
"profile": {
"firstName": "John",
"lastName": "Doe",
"age": 30
},
"addresses": [
{
"street": "123 Main St",
"city": "Springfield",
"zip": "12345"
},
{
"street": "456 Elm St",
"city": "Shelbyville",
"zip": "67890"
}
],
"createdAt": "2024-08-21T12:34:56Z",
"createdBy": "adminUserId"
}
π€ 4. Decision-Making for Firestore Schema Design
4.1 Sense-Check Questions
- π Is the Field Name Descriptive?
- π’ Should This Be Singular or Plural?
- π Is There Clarity Across the Database?
4.2 Practical Examples
- π Naming ID Fields: Use
cardId for clarity outside the cards collection
- π Choosing Field Names for Relationships:
userRef for single references, userIds for lists
4.3 Things to Avoid
- β οΈ Reserved Keywords: Avoid
key, type, ref
- π« Ambiguous Names: Avoid
data, info, value
4.4 Summary of Best Practices
- π Consistency Is Key
- π Clarity Over Brevity
- π§ββοΈ Avoid Over-Complexity
- π Naming: PascalCase (
CustomUserCard, PrimaryActionButton)
- π File Naming: Lowercase with underscores (
custom_user_card.dart)
5.2 Custom Functions
- πͺ Naming: camelCase (
fetchUserData, calculateTotalCost)
- π Arguments and Parameters: camelCase (
userId, totalAmount)
5.3 State Variables
- π Naming: camelCase (
isLoading, userName, itemList)
5.4 Firebase Collections and Fields
| Type | Convention | Example |
|---|
| π Collections | camelCase | userProfiles, orderHistory |
| π·οΈ Fields | camelCase | firstName, lastLoginTime |
| π€ String | fieldName: String | userName: String |
| π’ Integer | fieldName: Integer | age: Integer |
| β
Boolean | fieldName: Boolean | isActive: Boolean |
| β° Timestamp | fieldName: Timestamp | createdAt: Timestamp |
π By following these guidelines, even beginners can create clean, maintainable, and scalable app structures in FlutterFlow!