Skip to content

Support generating value-based models in Flutter from Serverpod YAML files #3463

Description

@dkbast

Problem to Solve

Serverpod currently generates models primarily for use with backend communication. However, in Flutter apps, especially in offline or view-model contexts, developers often need value-equatable, serializable models for local state management and UI logic. Without code generation support on the Flutter side, users will have to use another package for achieving pretty much the same what is already built in to Serverpod (eg use freezed, dart mappable etc etc)

Proposal

Enable model generation in Flutter apps directly from any serverpod.yaml file found in the workspace. This generation should:

  • Produce Dart classes that support value equality (e.g., == and hashCode).
  • Include JSON serialization methods.
  • Work without requiring network dependencies (i.e., models are purely structural/data-focused).
  • Be usable for offline apps, widget state management, or view models.

The codegen should be runnable anywhere in the workspace, aligning with Serverpod’s direction of broader workspace flexibility.

Use Case

A developer working on a Flutter app with offline-first capabilities or complex UI state where the user usually would resort to a generate state class. With this feature, they can use Serverpod’s YAML files to generate these models directly within the app, ensuring consistency and eliminating boilerplate, without needing to connect to the backend or run a server.

Alternatives

  • Using third-party model generators (e.g., Freezed or json_serializable) outside of Serverpod's toolchain.

Additional context

No response

How experienced are you with this library?

None

Are you interested in working on a PR for this?

  • I want to work on this

Activity

  1. added
    enhancement
    on Apr 24, 2025
  2. added theissue type on Apr 24, 2025
  3. added
    area: models
    on May 5, 2025
  4. added
    stake: onboarding
    on May 22, 2025
  5. vlidholt commented on Jun 18, 2025

    @vlidholt
    Collaborator

    This could potentially be nice, but it's definitely doable today. You just need to place the models somewhere in your server package. Having them generated on the server isn't really a problem (they will even be tree-shaken on server compilation). Perhaps this should be mentioned in the documentation as a starter, though. Created a documentation issue here: #3670

  6. added this to the Project Windex milestone on Jun 18, 2025
  7. added
    documentation
    on Jun 18, 2025
  8. removed this from the Project Windex milestone on Jun 18, 2025
  9. moved this from Backlog 🗂️ to Done 🚀 in Serverpod Frameworkson Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: modelsdocumentationenhancementstake: onboarding

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions