Comments (2)
@MarcelGarus Thanks for the detailed response! I am going to close this in favor of tracking #4
from data_classes.
Hmm good question. I guess we could try to add a meta-anmotation like
@Annotation(JsonSerializable())
to the mutable class to then add the actual annotation @JsonSerializable()
to the generated class.
But I'm not even sure you can add annotations in generated files...
Also, this issue doesn't have the highest priority right now, so it'll take some time until I evaluate/implement this. Of course you're welcome to contribute to the project, if you want to!
In the meantime, you can of course add @JsonSerializable
to the mutable class and use User.toMutable().toJson()
and User.fromMutable(MutableUser.fromJson(json))
although this is more boilerplate.
Oh and also, take into consideration that static extension methods are actively being worked on by the Dart team right now, so soon you'll be able to define User.toJson() => this.toMutable().toJson()
in the original file.
from data_classes.
Related Issues (9)
- Name annotation more intuitively HOT 1
- Optional named constructor parameters
- Exclude fields from generated copyWith or == methods
- `copyWith` probably handles nulls incorrectly HOT 9
- The future of this package HOT 8
- Generated code is not compilable HOT 3
- Add support for generating getters for an enum field HOT 2
- If mutable class extends a class, the immutable class should extend that too
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from data_classes.