Skip to content

Account Management

ShipFlutter provides a comprehensive account management system that handles user authentication, payments, consent and settings. The account system is built on top of Firebase Authentication and RevenueCat for mobile or LemonSqueezy for web.

Account Structure

The account system is divided into three main components:

  1. Account: Handles user identity and basic profile information (setup)
  2. Payments: Manages subscriptions and entitlements (setup)
  3. Consent: Manages user consent for data collection (setup)
  4. Settings & Preferences: User preferences and app configuration

User Identity

Each user account is associated with:

  1. Unique identifier
  2. Authentication method (email, social, anonymous)
  3. Basic profile (name, email, avatar)
  4. Entitlements (active subscriptions)

ShipFlutter includes a consent management system that allows users to control their data privacy preferences:

UserConsent(
analyticsStorage: true,
adUserData: false,
adPersonalization: false,
adStorage: false,
functionalityStorage: true,
personalizationStorage: false,
securityStorage: true,
errorsData: true,
)

The consent system provides:

  1. Customizable consent banner
  2. Granular privacy controls
  3. Persistence across sessions
  4. Integration with analytics and advertising

Settings Management

The settings system provides a flexible way to manage user preferences:

Available Settings

  1. Theme preferences (system, light, dark)
  2. Account information
  3. Privacy and consent controls
  4. Subscription management

Implementation

The settings system uses a controller-service pattern:

  • settings_controller.dart: Manages the UI state and user interactions
  • settings_service.dart: Handles the persistence of settings
  • settings_view.dart: Displays the settings UI
// Example: Updating theme mode
await settingsController.dispatch(ThemeMode.dark);

Account and Payments Integration

ShipFlutter seamlessly integrates user accounts with the payment system:

  1. Account Creation

    • Users can start with anonymous accounts
    • Upgrade to full accounts when needed
    • Social auth providers supported
  2. Payment Integration

    • RevenueCat handles subscriptions for mobile
    • LemonSqueezy handles subscriptions for web
    • Webhooks integration for both
    • Cross-platform purchase sync
  3. Account State

    Get and track account state in your app using the AccountService and the Account class:

    Account(
    id: 'user_id',
    type: CredentialsType.email,
    entitlements: [/* active subscriptions */],
    // ...other fields
    )

Best Practices

  1. Account Management

    • Always check account.hasActiveEntitlement() before accessing premium features
    • Use the account stream to react to changes in real-time
    • Handle anonymous accounts appropriately
  2. User Privacy

    • Always respect user consent settings
    • Only collect necessary data
    • Provide clear privacy controls
  3. Settings

    • Keep settings synchronized across devices
    • Provide defaults for all settings
    • Handle settings changes gracefully