// ignore_for_file: invalid_annotation_target import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:isekai_wiki/utils/utils.dart'; part 'page_info.freezed.dart'; part 'page_info.g.dart'; @JsonSerializable() class PageInfo { int pageid; int ns; String title; String? subtitle; String? displayTitle; @JsonKey(name: "extract") String? description; String? contentmodel; String? pagelanguage; String? pagelanguagehtmlcode; String? pagelanguagedir; @JsonKey(fromJson: _inwatchlistFromInt, toJson: _inwatchlistToInt) bool? inwatchlist; @JsonKey(name: "touched") DateTime? updatedTime; int? lastrevid; int? length; String? fullurl; String? editurl; String? canonicalurl; PageInfo({ required this.pageid, required this.ns, required this.title, this.subtitle, this.displayTitle, this.description, this.contentmodel, this.pagelanguage, this.pagelanguagehtmlcode, this.pagelanguagedir, this.inwatchlist, this.updatedTime, this.lastrevid, this.length, this.fullurl, this.editurl, this.canonicalurl, }); String get mainTitle { return displayTitle ?? title; } String? get mainCategory { return null; } factory PageInfo.fromJson(Map json) => _$PageInfoFromJson(json); Map toJson() => _$PageInfoToJson(this); static bool? _inwatchlistFromInt(int? val) { if (val != null) { return val == 1; } else { return null; } } static int? _inwatchlistToInt(bool? val) { if (val != null) { return val ? 1 : 0; } else { return null; } } } @Freezed(copyWith: false) class PagesResponse with _$PagesResponse { factory PagesResponse({required List pages}) = _PageResponse; factory PagesResponse.fromJson(Map json) => _$PagesResponseFromJson(json); } @Freezed(copyWith: false) class PageImageInfo with _$PageImageInfo { factory PageImageInfo({required String source, int? width, int? height}) = _PageImageInfo; factory PageImageInfo.fromJson(Map json) => _$PageImageInfoFromJson(json); }