freezed
freezed copied to clipboard
Add field name strings as static members of class to avoid typing them manually when needed
https://gist.github.com/dannnnthemannnn/f22b94c586c26a0909be073d2cceed42
@freezed
abstract class Discussion with _$Discussion {
factory Discussion({
DateTime scheduledTime,
bool isPublic,
List<String> participantIds,
}) = _Discussion;
// Add Helper field name somehow to generated class similar to this:
static const scheduledTimeField = 'scheduledTime';
static const isPublicField = 'isPublic';
static const participantIds = 'participantIds';
}
This could be added to the generated $Discussion class, such that we have:
print($Dicussion.nameOf.scheduledTime) // scheduledTime
I want this feature too 👀
Would this make more sense on json_serializable as this is probably most used with json serialization/deserialization?
Would love to have it as well.
Hey, this would be great. Is there any way I could help? Beside PR? I feel that it would take too much time for me to dive into your codebase.
I am certainly going to donate once this is the feature in freezed package :-)
Thanks for consideration!
I have no plan to implement this, so closing.
IMO this is not the responsibility of Freezed, and should instead be done by a separate code-generator.