feedback models added

This commit is contained in:
amirrezaghabeli
2025-08-17 12:29:12 +03:30
parent dfe3e21068
commit 5bb7326c76
21 changed files with 1969 additions and 94 deletions
@@ -0,0 +1,18 @@
// ignore_for_file: invalid_annotation_target
import 'package:freezed_annotation/freezed_annotation.dart';
part 'error_model.freezed.dart';
part 'error_model.g.dart';
@freezed
abstract class ErrorModel with _$ErrorModel {
const factory ErrorModel({
required String? message,
required String? code,
required String? details,
}) = _ErrorModel;
factory ErrorModel.fromJson(Map<String, dynamic> json) =>
_$ErrorModelFromJson(json);
}
@@ -0,0 +1,283 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// 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 'error_model.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$ErrorModel {
String? get message; String? get code; String? get details;
/// Create a copy of ErrorModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$ErrorModelCopyWith<ErrorModel> get copyWith => _$ErrorModelCopyWithImpl<ErrorModel>(this as ErrorModel, _$identity);
/// Serializes this ErrorModel to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is ErrorModel&&(identical(other.message, message) || other.message == message)&&(identical(other.code, code) || other.code == code)&&(identical(other.details, details) || other.details == details));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,message,code,details);
@override
String toString() {
return 'ErrorModel(message: $message, code: $code, details: $details)';
}
}
/// @nodoc
abstract mixin class $ErrorModelCopyWith<$Res> {
factory $ErrorModelCopyWith(ErrorModel value, $Res Function(ErrorModel) _then) = _$ErrorModelCopyWithImpl;
@useResult
$Res call({
String? message, String? code, String? details
});
}
/// @nodoc
class _$ErrorModelCopyWithImpl<$Res>
implements $ErrorModelCopyWith<$Res> {
_$ErrorModelCopyWithImpl(this._self, this._then);
final ErrorModel _self;
final $Res Function(ErrorModel) _then;
/// Create a copy of ErrorModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? message = freezed,Object? code = freezed,Object? details = freezed,}) {
return _then(_self.copyWith(
message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable
as String?,code: freezed == code ? _self.code : code // ignore: cast_nullable_to_non_nullable
as String?,details: freezed == details ? _self.details : details // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
/// Adds pattern-matching-related methods to [ErrorModel].
extension ErrorModelPatterns on ErrorModel {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _ErrorModel value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _ErrorModel() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _ErrorModel value) $default,){
final _that = this;
switch (_that) {
case _ErrorModel():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _ErrorModel value)? $default,){
final _that = this;
switch (_that) {
case _ErrorModel() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String? message, String? code, String? details)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ErrorModel() when $default != null:
return $default(_that.message,_that.code,_that.details);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? message, String? code, String? details) $default,) {final _that = this;
switch (_that) {
case _ErrorModel():
return $default(_that.message,_that.code,_that.details);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String? message, String? code, String? details)? $default,) {final _that = this;
switch (_that) {
case _ErrorModel() when $default != null:
return $default(_that.message,_that.code,_that.details);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _ErrorModel implements ErrorModel {
const _ErrorModel({required this.message, required this.code, required this.details});
factory _ErrorModel.fromJson(Map<String, dynamic> json) => _$ErrorModelFromJson(json);
@override final String? message;
@override final String? code;
@override final String? details;
/// Create a copy of ErrorModel
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$ErrorModelCopyWith<_ErrorModel> get copyWith => __$ErrorModelCopyWithImpl<_ErrorModel>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$ErrorModelToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ErrorModel&&(identical(other.message, message) || other.message == message)&&(identical(other.code, code) || other.code == code)&&(identical(other.details, details) || other.details == details));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,message,code,details);
@override
String toString() {
return 'ErrorModel(message: $message, code: $code, details: $details)';
}
}
/// @nodoc
abstract mixin class _$ErrorModelCopyWith<$Res> implements $ErrorModelCopyWith<$Res> {
factory _$ErrorModelCopyWith(_ErrorModel value, $Res Function(_ErrorModel) _then) = __$ErrorModelCopyWithImpl;
@override @useResult
$Res call({
String? message, String? code, String? details
});
}
/// @nodoc
class __$ErrorModelCopyWithImpl<$Res>
implements _$ErrorModelCopyWith<$Res> {
__$ErrorModelCopyWithImpl(this._self, this._then);
final _ErrorModel _self;
final $Res Function(_ErrorModel) _then;
/// Create a copy of ErrorModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? message = freezed,Object? code = freezed,Object? details = freezed,}) {
return _then(_ErrorModel(
message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable
as String?,code: freezed == code ? _self.code : code // ignore: cast_nullable_to_non_nullable
as String?,details: freezed == details ? _self.details : details // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
// dart format on
@@ -0,0 +1,20 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'error_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_ErrorModel _$ErrorModelFromJson(Map<String, dynamic> json) => _ErrorModel(
message: json['message'] as String?,
code: json['code'] as String?,
details: json['details'] as String?,
);
Map<String, dynamic> _$ErrorModelToJson(_ErrorModel instance) =>
<String, dynamic>{
'message': instance.message,
'code': instance.code,
'details': instance.details,
};