You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support generating value-based models in Flutter from Serverpod YAML files #3463
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.
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
Activity
vlidholt commentedon Jun 18, 2025
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