json_serializable.dart
json_serializable.dart copied to clipboard
Make JsonKey's defaultValue a Function? type
I would like to supply a DateTime.now()
as a defaultValue
to JsonKey
, but as it's not a const
it's not possible to add it, however if it was of type Function?
i could pass it a function which would return a value in the same way as toJson
and fromJson
, e.g. static DateTime newDate() => DateTime.now();
This would be a breaking change so not sure if it's feasible, but it would make the API more flexible perhaps?
Dart SDK version: 2.17.6 (stable) (Tue Jul 12 12:54:37 2022 +0200) on "macos_arm64"