135 lines
3.9 KiB
Dart
135 lines
3.9 KiB
Dart
|
import 'package:flutter/foundation.dart';
|
||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||
|
|
||
|
import 'teaser_image.dart';
|
||
|
|
||
|
part 'news.freezed.dart';
|
||
|
part 'news.g.dart';
|
||
|
|
||
|
@freezed
|
||
|
class News with _$News {
|
||
|
const factory News({
|
||
|
String? title,
|
||
|
TeaserImage? teaserImage,
|
||
|
TeaserImage? brandingImage,
|
||
|
String? date,
|
||
|
String? type,
|
||
|
}) = _News;
|
||
|
|
||
|
factory News.fromJson(Map<String, dynamic> json) => _$NewsFromJson(json);
|
||
|
}
|
||
|
|
||
|
// old manual implementation:
|
||
|
|
||
|
// final String sophoraId;
|
||
|
// final String externalId;
|
||
|
// final String title;
|
||
|
// final TeaserImage? teaserImage;
|
||
|
// final TeaserImage? brandingImage;
|
||
|
// final String date;
|
||
|
// final String updateCheckUrl;
|
||
|
// final int regionId;
|
||
|
// final String details;
|
||
|
// final String detailsweb;
|
||
|
// final String shareURL;
|
||
|
// final String topline;
|
||
|
// final String firstSentence;
|
||
|
// final String type;
|
||
|
// News({
|
||
|
// required this.sophoraId,
|
||
|
// required this.externalId,
|
||
|
// required this.title,
|
||
|
// this.teaserImage,
|
||
|
// this.brandingImage,
|
||
|
// required this.date,
|
||
|
// required this.updateCheckUrl,
|
||
|
// required this.regionId,
|
||
|
// required this.details,
|
||
|
// required this.detailsweb,
|
||
|
// required this.shareURL,
|
||
|
// required this.topline,
|
||
|
// required this.firstSentence,
|
||
|
// required this.type,
|
||
|
// });
|
||
|
|
||
|
// News copyWith({
|
||
|
// String? sophoraId,
|
||
|
// String? externalId,
|
||
|
// String? title,
|
||
|
// TeaserImage? teaserImage,
|
||
|
// TeaserImage? brandingImage,
|
||
|
// String? date,
|
||
|
// String? updateCheckUrl,
|
||
|
// int? regionId,
|
||
|
// String? details,
|
||
|
// String? detailsweb,
|
||
|
// String? shareURL,
|
||
|
// String? topline,
|
||
|
// String? firstSentence,
|
||
|
// String? type,
|
||
|
// }) {
|
||
|
// return News(
|
||
|
// sophoraId: sophoraId ?? this.sophoraId,
|
||
|
// externalId: externalId ?? this.externalId,
|
||
|
// title: title ?? this.title,
|
||
|
// teaserImage: teaserImage ?? this.teaserImage,
|
||
|
// brandingImage: brandingImage ?? this.brandingImage,
|
||
|
// date: date ?? this.date,
|
||
|
// updateCheckUrl: updateCheckUrl ?? this.updateCheckUrl,
|
||
|
// regionId: regionId ?? this.regionId,
|
||
|
// details: details ?? this.details,
|
||
|
// detailsweb: detailsweb ?? this.detailsweb,
|
||
|
// shareURL: shareURL ?? this.shareURL,
|
||
|
// topline: topline ?? this.topline,
|
||
|
// firstSentence: firstSentence ?? this.firstSentence,
|
||
|
// type: type ?? this.type,
|
||
|
// );
|
||
|
// }
|
||
|
|
||
|
// Map<String, dynamic> toMap() {
|
||
|
// return {
|
||
|
// 'sophoraId': sophoraId,
|
||
|
// 'externalId': externalId,
|
||
|
// 'title': title,
|
||
|
// 'teaserImage': teaserImage?.toMap(),
|
||
|
// 'brandingImage': brandingImage?.toMap(),
|
||
|
// 'date': date,
|
||
|
// 'updateCheckUrl': updateCheckUrl,
|
||
|
// 'regionId': regionId,
|
||
|
// 'details': details,
|
||
|
// 'detailsweb': detailsweb,
|
||
|
// 'shareURL': shareURL,
|
||
|
// 'topline': topline,
|
||
|
// 'firstSentence': firstSentence,
|
||
|
// 'type': type,
|
||
|
// };
|
||
|
// }
|
||
|
|
||
|
// factory News.fromMap(Map<String, dynamic> map) {
|
||
|
// return News(
|
||
|
// sophoraId: map['sophoraId'] ?? '',
|
||
|
// externalId: map['externalId'] ?? '',
|
||
|
// title: map['title'] ?? '',
|
||
|
// teaserImage: map['teaserImage'] != null
|
||
|
// ? TeaserImage.fromMap(map['teaserImage'])
|
||
|
// : null,
|
||
|
// brandingImage: map['brandingImage'] != null
|
||
|
// ? TeaserImage.fromMap(map['brandingImage'])
|
||
|
// : null,
|
||
|
// date: map['date'] ?? '',
|
||
|
// updateCheckUrl: map['updateCheckUrl'] ?? '',
|
||
|
// regionId: map['regionId']?.toInt() ?? 0,
|
||
|
// details: map['details'] ?? '',
|
||
|
// detailsweb: map['detailsweb'] ?? '',
|
||
|
// shareURL: map['shareURL'] ?? '',
|
||
|
// topline: map['topline'] ?? '',
|
||
|
// firstSentence: map['firstSentence'] ?? '',
|
||
|
// type: map['type'] ?? '',
|
||
|
// );
|
||
|
// }
|
||
|
|
||
|
// String toJson() => json.encode(toMap());
|
||
|
|
||
|
// factory News.fromJson(String source) => News.fromMap(json.decode(source));
|
||
|
// }
|