I have this freezed part
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'user_model.freezed.dart';
part 'user_model.g.dart';
@freezed
class UserModel with _$UserModel {
factory UserModel({
required String id,
@Default('') String uniqueId,
@Default(DateTime.now()) DateTime dob,
}) = _UserModel;
factory UserModel.fromJson(Map<String, dynamic> json) =>
_$UserModelFromJson(json);
}
But am not able to generate the required file due to DateTime.now().
if I do something like this:
factory UserModel({
required String id,
@Default('') String uniqueId,
required DateTime dob,
}) = _UserModel;
it will work but I have to manually edit the generated data to this:
dob: (json['dob'] as Timestamp?)?.toDate() ?? DateTime.now()
from
dob: DateTime.parse(json['dob'] as String),
I can't keep manually editing it all time.
Please how do I generate the model class including Datetime.