I have a freezed class that looks like this:
@freezed
abstract class GiftGiver with _$GiftGiver {
const factory GiftGiver({
String? id,
String? uid,
String? imageUrl,
String? giftDetails,
String? listingDate,
@Default(5) int listingFor,
Timestamp? pickUpTime,
@Default(false) canLeaveOutside,
}) = _GiftGiver;
factory GiftGiver.fromJson(Map<String, dynamic> json) =>
_$GiftGiverFromJson(json);
}
The freezed class is generated fine but .g.dart class is not generated as I have Timestamp type. I saw some solution at https://github.com/rrousselGit/freezed#fromjson---classes-with-multiple-constructors but I am not understanding how to apply it to solve my problem.
Maybe you need to add the
json_serializablepackage in thedev_dependenciessection in thepubspec.yamlfile.If this is your case, delete the
pubspeck.lockfile, and then run the commandflutter pub getto generate the filepubspeck.lockagain.Then, run the command
flutter packages pub run build_runner build --delete-conflicting-outputs and fixto generate the.gfile