πŸš€ FlutterFlow Best Practices Cheat Sheet

A comprehensive guide to best practices in FlutterFlow development

πŸš€ 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

CategoryConventionExample
πŸ”€ General FieldscamelCasefirstName, emailAddress
πŸ†” ID FieldsSpecific prefix/suffixuserId, orderId
⏰ Timestamp FieldsSpecific namescreatedAt, updatedAt
πŸ‘€ User Reference FieldsSpecific namescreatedBy, updatedBy

3.2 Lists and References

TypeConventionExample
πŸ“š Lists of ItemsPlural camelCasetags, categories
πŸ”— Document ReferencesSingular with Ref suffixuserRef, postRef
πŸ”’ Lists of Related IDsPlural with Ids suffixuserIds, productIds

3.3 Nested Data Types

TypeConventionExample
πŸ—ΊοΈ Maps (Objects)Singular, optional Map suffixaddressMap, settingsMap
πŸ“Š Arrays of MapsPlural, optional List/Maps/Array suffixaddresses, 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

πŸ› οΈ 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

TypeConventionExample
πŸ“š CollectionscamelCaseuserProfiles, orderHistory
🏷️ FieldscamelCasefirstName, lastLoginTime
πŸ”€ StringfieldName: StringuserName: String
πŸ”’ IntegerfieldName: Integerage: Integer
βœ… BooleanfieldName: BooleanisActive: Boolean
⏰ TimestampfieldName: TimestampcreatedAt: Timestamp

πŸŽ‰ By following these guidelines, even beginners can create clean, maintainable, and scalable app structures in FlutterFlow!