✨ Post tags
This commit is contained in:
@ -18,7 +18,7 @@ class SnPost with _$SnPost {
|
||||
required String language,
|
||||
required String? alias,
|
||||
required String? aliasPrefix,
|
||||
@Default([]) List<dynamic> tags,
|
||||
@Default([]) List<SnPostTag> tags,
|
||||
@Default([]) List<dynamic> categories,
|
||||
required List<SnPost>? replies,
|
||||
required int? replyId,
|
||||
@ -50,6 +50,23 @@ class SnPost with _$SnPost {
|
||||
};
|
||||
}
|
||||
|
||||
@freezed
|
||||
class SnPostTag with _$SnPostTag {
|
||||
const factory SnPostTag({
|
||||
required int id,
|
||||
required DateTime createdAt,
|
||||
required DateTime updatedAt,
|
||||
required dynamic deletedAt,
|
||||
required String alias,
|
||||
required String name,
|
||||
required String description,
|
||||
required dynamic posts,
|
||||
}) = _SnPostTag;
|
||||
|
||||
factory SnPostTag.fromJson(Map<String, Object?> json) =>
|
||||
_$SnPostTagFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class SnPostPreload with _$SnPostPreload {
|
||||
const factory SnPostPreload({
|
||||
|
@ -29,7 +29,7 @@ mixin _$SnPost {
|
||||
String get language => throw _privateConstructorUsedError;
|
||||
String? get alias => throw _privateConstructorUsedError;
|
||||
String? get aliasPrefix => throw _privateConstructorUsedError;
|
||||
List<dynamic> get tags => throw _privateConstructorUsedError;
|
||||
List<SnPostTag> get tags => throw _privateConstructorUsedError;
|
||||
List<dynamic> get categories => throw _privateConstructorUsedError;
|
||||
List<SnPost>? get replies => throw _privateConstructorUsedError;
|
||||
int? get replyId => throw _privateConstructorUsedError;
|
||||
@ -76,7 +76,7 @@ abstract class $SnPostCopyWith<$Res> {
|
||||
String language,
|
||||
String? alias,
|
||||
String? aliasPrefix,
|
||||
List<dynamic> tags,
|
||||
List<SnPostTag> tags,
|
||||
List<dynamic> categories,
|
||||
List<SnPost>? replies,
|
||||
int? replyId,
|
||||
@ -193,7 +193,7 @@ class _$SnPostCopyWithImpl<$Res, $Val extends SnPost>
|
||||
tags: null == tags
|
||||
? _value.tags
|
||||
: tags // ignore: cast_nullable_to_non_nullable
|
||||
as List<dynamic>,
|
||||
as List<SnPostTag>,
|
||||
categories: null == categories
|
||||
? _value.categories
|
||||
: categories // ignore: cast_nullable_to_non_nullable
|
||||
@ -361,7 +361,7 @@ abstract class _$$SnPostImplCopyWith<$Res> implements $SnPostCopyWith<$Res> {
|
||||
String language,
|
||||
String? alias,
|
||||
String? aliasPrefix,
|
||||
List<dynamic> tags,
|
||||
List<SnPostTag> tags,
|
||||
List<dynamic> categories,
|
||||
List<SnPost>? replies,
|
||||
int? replyId,
|
||||
@ -481,7 +481,7 @@ class __$$SnPostImplCopyWithImpl<$Res>
|
||||
tags: null == tags
|
||||
? _value._tags
|
||||
: tags // ignore: cast_nullable_to_non_nullable
|
||||
as List<dynamic>,
|
||||
as List<SnPostTag>,
|
||||
categories: null == categories
|
||||
? _value._categories
|
||||
: categories // ignore: cast_nullable_to_non_nullable
|
||||
@ -583,7 +583,7 @@ class _$SnPostImpl extends _SnPost {
|
||||
required this.language,
|
||||
required this.alias,
|
||||
required this.aliasPrefix,
|
||||
final List<dynamic> tags = const [],
|
||||
final List<SnPostTag> tags = const [],
|
||||
final List<dynamic> categories = const [],
|
||||
required final List<SnPost>? replies,
|
||||
required this.replyId,
|
||||
@ -640,10 +640,10 @@ class _$SnPostImpl extends _SnPost {
|
||||
final String? alias;
|
||||
@override
|
||||
final String? aliasPrefix;
|
||||
final List<dynamic> _tags;
|
||||
final List<SnPostTag> _tags;
|
||||
@override
|
||||
@JsonKey()
|
||||
List<dynamic> get tags {
|
||||
List<SnPostTag> get tags {
|
||||
if (_tags is EqualUnmodifiableListView) return _tags;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_tags);
|
||||
@ -852,7 +852,7 @@ abstract class _SnPost extends SnPost {
|
||||
required final String language,
|
||||
required final String? alias,
|
||||
required final String? aliasPrefix,
|
||||
final List<dynamic> tags,
|
||||
final List<SnPostTag> tags,
|
||||
final List<dynamic> categories,
|
||||
required final List<SnPost>? replies,
|
||||
required final int? replyId,
|
||||
@ -897,7 +897,7 @@ abstract class _SnPost extends SnPost {
|
||||
@override
|
||||
String? get aliasPrefix;
|
||||
@override
|
||||
List<dynamic> get tags;
|
||||
List<SnPostTag> get tags;
|
||||
@override
|
||||
List<dynamic> get categories;
|
||||
@override
|
||||
@ -949,6 +949,310 @@ abstract class _SnPost extends SnPost {
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
SnPostTag _$SnPostTagFromJson(Map<String, dynamic> json) {
|
||||
return _SnPostTag.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$SnPostTag {
|
||||
int get id => throw _privateConstructorUsedError;
|
||||
DateTime get createdAt => throw _privateConstructorUsedError;
|
||||
DateTime get updatedAt => throw _privateConstructorUsedError;
|
||||
dynamic get deletedAt => throw _privateConstructorUsedError;
|
||||
String get alias => throw _privateConstructorUsedError;
|
||||
String get name => throw _privateConstructorUsedError;
|
||||
String get description => throw _privateConstructorUsedError;
|
||||
dynamic get posts => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this SnPostTag to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of SnPostTag
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$SnPostTagCopyWith<SnPostTag> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $SnPostTagCopyWith<$Res> {
|
||||
factory $SnPostTagCopyWith(SnPostTag value, $Res Function(SnPostTag) then) =
|
||||
_$SnPostTagCopyWithImpl<$Res, SnPostTag>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{int id,
|
||||
DateTime createdAt,
|
||||
DateTime updatedAt,
|
||||
dynamic deletedAt,
|
||||
String alias,
|
||||
String name,
|
||||
String description,
|
||||
dynamic posts});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$SnPostTagCopyWithImpl<$Res, $Val extends SnPostTag>
|
||||
implements $SnPostTagCopyWith<$Res> {
|
||||
_$SnPostTagCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of SnPostTag
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? createdAt = null,
|
||||
Object? updatedAt = null,
|
||||
Object? deletedAt = freezed,
|
||||
Object? alias = null,
|
||||
Object? name = null,
|
||||
Object? description = null,
|
||||
Object? posts = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
createdAt: null == createdAt
|
||||
? _value.createdAt
|
||||
: createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
updatedAt: null == updatedAt
|
||||
? _value.updatedAt
|
||||
: updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
deletedAt: freezed == deletedAt
|
||||
? _value.deletedAt
|
||||
: deletedAt // ignore: cast_nullable_to_non_nullable
|
||||
as dynamic,
|
||||
alias: null == alias
|
||||
? _value.alias
|
||||
: alias // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
name: null == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
description: null == description
|
||||
? _value.description
|
||||
: description // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
posts: freezed == posts
|
||||
? _value.posts
|
||||
: posts // ignore: cast_nullable_to_non_nullable
|
||||
as dynamic,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SnPostTagImplCopyWith<$Res>
|
||||
implements $SnPostTagCopyWith<$Res> {
|
||||
factory _$$SnPostTagImplCopyWith(
|
||||
_$SnPostTagImpl value, $Res Function(_$SnPostTagImpl) then) =
|
||||
__$$SnPostTagImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{int id,
|
||||
DateTime createdAt,
|
||||
DateTime updatedAt,
|
||||
dynamic deletedAt,
|
||||
String alias,
|
||||
String name,
|
||||
String description,
|
||||
dynamic posts});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SnPostTagImplCopyWithImpl<$Res>
|
||||
extends _$SnPostTagCopyWithImpl<$Res, _$SnPostTagImpl>
|
||||
implements _$$SnPostTagImplCopyWith<$Res> {
|
||||
__$$SnPostTagImplCopyWithImpl(
|
||||
_$SnPostTagImpl _value, $Res Function(_$SnPostTagImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of SnPostTag
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? createdAt = null,
|
||||
Object? updatedAt = null,
|
||||
Object? deletedAt = freezed,
|
||||
Object? alias = null,
|
||||
Object? name = null,
|
||||
Object? description = null,
|
||||
Object? posts = freezed,
|
||||
}) {
|
||||
return _then(_$SnPostTagImpl(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
createdAt: null == createdAt
|
||||
? _value.createdAt
|
||||
: createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
updatedAt: null == updatedAt
|
||||
? _value.updatedAt
|
||||
: updatedAt // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
deletedAt: freezed == deletedAt
|
||||
? _value.deletedAt
|
||||
: deletedAt // ignore: cast_nullable_to_non_nullable
|
||||
as dynamic,
|
||||
alias: null == alias
|
||||
? _value.alias
|
||||
: alias // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
name: null == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
description: null == description
|
||||
? _value.description
|
||||
: description // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
posts: freezed == posts
|
||||
? _value.posts
|
||||
: posts // ignore: cast_nullable_to_non_nullable
|
||||
as dynamic,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$SnPostTagImpl implements _SnPostTag {
|
||||
const _$SnPostTagImpl(
|
||||
{required this.id,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.deletedAt,
|
||||
required this.alias,
|
||||
required this.name,
|
||||
required this.description,
|
||||
required this.posts});
|
||||
|
||||
factory _$SnPostTagImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$SnPostTagImplFromJson(json);
|
||||
|
||||
@override
|
||||
final int id;
|
||||
@override
|
||||
final DateTime createdAt;
|
||||
@override
|
||||
final DateTime updatedAt;
|
||||
@override
|
||||
final dynamic deletedAt;
|
||||
@override
|
||||
final String alias;
|
||||
@override
|
||||
final String name;
|
||||
@override
|
||||
final String description;
|
||||
@override
|
||||
final dynamic posts;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SnPostTag(id: $id, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, alias: $alias, name: $name, description: $description, posts: $posts)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SnPostTagImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.createdAt, createdAt) ||
|
||||
other.createdAt == createdAt) &&
|
||||
(identical(other.updatedAt, updatedAt) ||
|
||||
other.updatedAt == updatedAt) &&
|
||||
const DeepCollectionEquality().equals(other.deletedAt, deletedAt) &&
|
||||
(identical(other.alias, alias) || other.alias == alias) &&
|
||||
(identical(other.name, name) || other.name == name) &&
|
||||
(identical(other.description, description) ||
|
||||
other.description == description) &&
|
||||
const DeepCollectionEquality().equals(other.posts, posts));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
id,
|
||||
createdAt,
|
||||
updatedAt,
|
||||
const DeepCollectionEquality().hash(deletedAt),
|
||||
alias,
|
||||
name,
|
||||
description,
|
||||
const DeepCollectionEquality().hash(posts));
|
||||
|
||||
/// Create a copy of SnPostTag
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$SnPostTagImplCopyWith<_$SnPostTagImpl> get copyWith =>
|
||||
__$$SnPostTagImplCopyWithImpl<_$SnPostTagImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$SnPostTagImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _SnPostTag implements SnPostTag {
|
||||
const factory _SnPostTag(
|
||||
{required final int id,
|
||||
required final DateTime createdAt,
|
||||
required final DateTime updatedAt,
|
||||
required final dynamic deletedAt,
|
||||
required final String alias,
|
||||
required final String name,
|
||||
required final String description,
|
||||
required final dynamic posts}) = _$SnPostTagImpl;
|
||||
|
||||
factory _SnPostTag.fromJson(Map<String, dynamic> json) =
|
||||
_$SnPostTagImpl.fromJson;
|
||||
|
||||
@override
|
||||
int get id;
|
||||
@override
|
||||
DateTime get createdAt;
|
||||
@override
|
||||
DateTime get updatedAt;
|
||||
@override
|
||||
dynamic get deletedAt;
|
||||
@override
|
||||
String get alias;
|
||||
@override
|
||||
String get name;
|
||||
@override
|
||||
String get description;
|
||||
@override
|
||||
dynamic get posts;
|
||||
|
||||
/// Create a copy of SnPostTag
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$SnPostTagImplCopyWith<_$SnPostTagImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
SnPostPreload _$SnPostPreloadFromJson(Map<String, dynamic> json) {
|
||||
return _SnPostPreload.fromJson(json);
|
||||
}
|
||||
|
@ -18,7 +18,10 @@ _$SnPostImpl _$$SnPostImplFromJson(Map<String, dynamic> json) => _$SnPostImpl(
|
||||
language: json['language'] as String,
|
||||
alias: json['alias'] as String?,
|
||||
aliasPrefix: json['alias_prefix'] as String?,
|
||||
tags: json['tags'] as List<dynamic>? ?? const [],
|
||||
tags: (json['tags'] as List<dynamic>?)
|
||||
?.map((e) => SnPostTag.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
const [],
|
||||
categories: json['categories'] as List<dynamic>? ?? const [],
|
||||
replies: (json['replies'] as List<dynamic>?)
|
||||
?.map((e) => SnPost.fromJson(e as Map<String, dynamic>))
|
||||
@ -76,7 +79,7 @@ Map<String, dynamic> _$$SnPostImplToJson(_$SnPostImpl instance) =>
|
||||
'language': instance.language,
|
||||
'alias': instance.alias,
|
||||
'alias_prefix': instance.aliasPrefix,
|
||||
'tags': instance.tags,
|
||||
'tags': instance.tags.map((e) => e.toJson()).toList(),
|
||||
'categories': instance.categories,
|
||||
'replies': instance.replies?.map((e) => e.toJson()).toList(),
|
||||
'reply_id': instance.replyId,
|
||||
@ -100,6 +103,30 @@ Map<String, dynamic> _$$SnPostImplToJson(_$SnPostImpl instance) =>
|
||||
'preload': instance.preload?.toJson(),
|
||||
};
|
||||
|
||||
_$SnPostTagImpl _$$SnPostTagImplFromJson(Map<String, dynamic> json) =>
|
||||
_$SnPostTagImpl(
|
||||
id: (json['id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'],
|
||||
alias: json['alias'] as String,
|
||||
name: json['name'] as String,
|
||||
description: json['description'] as String,
|
||||
posts: json['posts'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$SnPostTagImplToJson(_$SnPostTagImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt,
|
||||
'alias': instance.alias,
|
||||
'name': instance.name,
|
||||
'description': instance.description,
|
||||
'posts': instance.posts,
|
||||
};
|
||||
|
||||
_$SnPostPreloadImpl _$$SnPostPreloadImplFromJson(Map<String, dynamic> json) =>
|
||||
_$SnPostPreloadImpl(
|
||||
thumbnail: json['thumbnail'] == null
|
||||
|
Reference in New Issue
Block a user