Создание коллекций
This commit is contained in:
27
lib/models/collection_dto.dart
Normal file
27
lib/models/collection_dto.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final collectionDto = collectionDtoFromJson(jsonString);
|
||||
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
part 'collection_dto.freezed.dart';
|
||||
part 'collection_dto.g.dart';
|
||||
|
||||
CollectionDto collectionDtoFromJson(String str) =>
|
||||
CollectionDto.fromJson(json.decode(str));
|
||||
|
||||
String collectionDtoToJson(CollectionDto data) => json.encode(data.toJson());
|
||||
|
||||
@freezed
|
||||
class CollectionDto with _$CollectionDto {
|
||||
const factory CollectionDto({
|
||||
required String desc,
|
||||
required String title,
|
||||
required bool isPublic,
|
||||
String? avatar,
|
||||
}) = _CollectionDto;
|
||||
|
||||
factory CollectionDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$CollectionDtoFromJson(json);
|
||||
}
|
||||
238
lib/models/collection_dto.freezed.dart
Normal file
238
lib/models/collection_dto.freezed.dart
Normal file
@@ -0,0 +1,238 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'collection_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
||||
);
|
||||
|
||||
CollectionDto _$CollectionDtoFromJson(Map<String, dynamic> json) {
|
||||
return _CollectionDto.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$CollectionDto {
|
||||
String get desc => throw _privateConstructorUsedError;
|
||||
String get title => throw _privateConstructorUsedError;
|
||||
bool get isPublic => throw _privateConstructorUsedError;
|
||||
String? get avatar => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this CollectionDto to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of CollectionDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$CollectionDtoCopyWith<CollectionDto> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $CollectionDtoCopyWith<$Res> {
|
||||
factory $CollectionDtoCopyWith(
|
||||
CollectionDto value,
|
||||
$Res Function(CollectionDto) then,
|
||||
) = _$CollectionDtoCopyWithImpl<$Res, CollectionDto>;
|
||||
@useResult
|
||||
$Res call({String desc, String title, bool isPublic, String? avatar});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$CollectionDtoCopyWithImpl<$Res, $Val extends CollectionDto>
|
||||
implements $CollectionDtoCopyWith<$Res> {
|
||||
_$CollectionDtoCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of CollectionDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? desc = null,
|
||||
Object? title = null,
|
||||
Object? isPublic = null,
|
||||
Object? avatar = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
desc:
|
||||
null == desc
|
||||
? _value.desc
|
||||
: desc // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
title:
|
||||
null == title
|
||||
? _value.title
|
||||
: title // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
isPublic:
|
||||
null == isPublic
|
||||
? _value.isPublic
|
||||
: isPublic // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
avatar:
|
||||
freezed == avatar
|
||||
? _value.avatar
|
||||
: avatar // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CollectionDtoImplCopyWith<$Res>
|
||||
implements $CollectionDtoCopyWith<$Res> {
|
||||
factory _$$CollectionDtoImplCopyWith(
|
||||
_$CollectionDtoImpl value,
|
||||
$Res Function(_$CollectionDtoImpl) then,
|
||||
) = __$$CollectionDtoImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({String desc, String title, bool isPublic, String? avatar});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CollectionDtoImplCopyWithImpl<$Res>
|
||||
extends _$CollectionDtoCopyWithImpl<$Res, _$CollectionDtoImpl>
|
||||
implements _$$CollectionDtoImplCopyWith<$Res> {
|
||||
__$$CollectionDtoImplCopyWithImpl(
|
||||
_$CollectionDtoImpl _value,
|
||||
$Res Function(_$CollectionDtoImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of CollectionDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? desc = null,
|
||||
Object? title = null,
|
||||
Object? isPublic = null,
|
||||
Object? avatar = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_$CollectionDtoImpl(
|
||||
desc:
|
||||
null == desc
|
||||
? _value.desc
|
||||
: desc // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
title:
|
||||
null == title
|
||||
? _value.title
|
||||
: title // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
isPublic:
|
||||
null == isPublic
|
||||
? _value.isPublic
|
||||
: isPublic // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
avatar:
|
||||
freezed == avatar
|
||||
? _value.avatar
|
||||
: avatar // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$CollectionDtoImpl implements _CollectionDto {
|
||||
const _$CollectionDtoImpl({
|
||||
required this.desc,
|
||||
required this.title,
|
||||
required this.isPublic,
|
||||
this.avatar,
|
||||
});
|
||||
|
||||
factory _$CollectionDtoImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$CollectionDtoImplFromJson(json);
|
||||
|
||||
@override
|
||||
final String desc;
|
||||
@override
|
||||
final String title;
|
||||
@override
|
||||
final bool isPublic;
|
||||
@override
|
||||
final String? avatar;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CollectionDto(desc: $desc, title: $title, isPublic: $isPublic, avatar: $avatar)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CollectionDtoImpl &&
|
||||
(identical(other.desc, desc) || other.desc == desc) &&
|
||||
(identical(other.title, title) || other.title == title) &&
|
||||
(identical(other.isPublic, isPublic) ||
|
||||
other.isPublic == isPublic) &&
|
||||
(identical(other.avatar, avatar) || other.avatar == avatar));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, desc, title, isPublic, avatar);
|
||||
|
||||
/// Create a copy of CollectionDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CollectionDtoImplCopyWith<_$CollectionDtoImpl> get copyWith =>
|
||||
__$$CollectionDtoImplCopyWithImpl<_$CollectionDtoImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$CollectionDtoImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _CollectionDto implements CollectionDto {
|
||||
const factory _CollectionDto({
|
||||
required final String desc,
|
||||
required final String title,
|
||||
required final bool isPublic,
|
||||
final String? avatar,
|
||||
}) = _$CollectionDtoImpl;
|
||||
|
||||
factory _CollectionDto.fromJson(Map<String, dynamic> json) =
|
||||
_$CollectionDtoImpl.fromJson;
|
||||
|
||||
@override
|
||||
String get desc;
|
||||
@override
|
||||
String get title;
|
||||
@override
|
||||
bool get isPublic;
|
||||
@override
|
||||
String? get avatar;
|
||||
|
||||
/// Create a copy of CollectionDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$CollectionDtoImplCopyWith<_$CollectionDtoImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
23
lib/models/collection_dto.g.dart
Normal file
23
lib/models/collection_dto.g.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'collection_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$CollectionDtoImpl _$$CollectionDtoImplFromJson(Map<String, dynamic> json) =>
|
||||
_$CollectionDtoImpl(
|
||||
desc: json['desc'] as String,
|
||||
title: json['title'] as String,
|
||||
isPublic: json['isPublic'] as bool,
|
||||
avatar: json['avatar'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$CollectionDtoImplToJson(_$CollectionDtoImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'desc': instance.desc,
|
||||
'title': instance.title,
|
||||
'isPublic': instance.isPublic,
|
||||
'avatar': instance.avatar,
|
||||
};
|
||||
Reference in New Issue
Block a user