# πŸš€ 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` ### 2.2 Widgets and Components - πŸ”  **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 ```json { "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 ## πŸ› οΈ 5. Custom Functions and Widgets in FlutterFlow ### 5.1 Custom Widgets - πŸ”  **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!