After defining some response data structure i'm trying to build @freezed
class, but i get this error:
Could not generate `toJson` code for `medias` because of type `Media`.
after some of research about this problem i can't found how can i resolve this error:
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:xxxx/screens/search_page/data/media.dart';
part 'account.g.dart';
part 'account.freezed.dart';
@freezed
class Account with _$Account{
const factory Account({
//...
required List<Media>medias,
//...
})=_Account;
factory Account.fromJson(Map<String, dynamic> json) =>
_$AccountFromJson(json);
}
@freezed
class Media with _$Media{
const factory Media(
{
required String shortCode,
required int createdTime,
//...
})=_Media;
factory Media.fromJson(Map<String, dynamic> json) =>
_$MediaFromJson(json);
}