fix settings
This commit is contained in:
42
lib/features/auth/data/models/user_model.dart
Normal file
42
lib/features/auth/data/models/user_model.dart
Normal file
@@ -0,0 +1,42 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import '../../domain/entities/user.dart';
|
||||
|
||||
part 'user_model.freezed.dart';
|
||||
part 'user_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class UserModel with _$UserModel {
|
||||
const factory UserModel({
|
||||
required String id,
|
||||
required String email,
|
||||
required String name,
|
||||
String? avatarUrl,
|
||||
required String token,
|
||||
DateTime? tokenExpiry,
|
||||
}) = _UserModel;
|
||||
|
||||
const UserModel._();
|
||||
|
||||
factory UserModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$UserModelFromJson(json);
|
||||
|
||||
/// Convert to domain entity
|
||||
User toEntity() => User(
|
||||
id: id,
|
||||
email: email,
|
||||
name: name,
|
||||
avatarUrl: avatarUrl,
|
||||
token: token,
|
||||
tokenExpiry: tokenExpiry,
|
||||
);
|
||||
|
||||
/// Create from domain entity
|
||||
factory UserModel.fromEntity(User user) => UserModel(
|
||||
id: user.id,
|
||||
email: user.email,
|
||||
name: user.name,
|
||||
avatarUrl: user.avatarUrl,
|
||||
token: user.token,
|
||||
tokenExpiry: user.tokenExpiry,
|
||||
);
|
||||
}
|
||||
259
lib/features/auth/data/models/user_model.freezed.dart
Normal file
259
lib/features/auth/data/models/user_model.freezed.dart
Normal file
@@ -0,0 +1,259 @@
|
||||
// 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 'user_model.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');
|
||||
|
||||
UserModel _$UserModelFromJson(Map<String, dynamic> json) {
|
||||
return _UserModel.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$UserModel {
|
||||
String get id => throw _privateConstructorUsedError;
|
||||
String get email => throw _privateConstructorUsedError;
|
||||
String get name => throw _privateConstructorUsedError;
|
||||
String? get avatarUrl => throw _privateConstructorUsedError;
|
||||
String get token => throw _privateConstructorUsedError;
|
||||
DateTime? get tokenExpiry => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$UserModelCopyWith<UserModel> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $UserModelCopyWith<$Res> {
|
||||
factory $UserModelCopyWith(UserModel value, $Res Function(UserModel) then) =
|
||||
_$UserModelCopyWithImpl<$Res, UserModel>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{String id,
|
||||
String email,
|
||||
String name,
|
||||
String? avatarUrl,
|
||||
String token,
|
||||
DateTime? tokenExpiry});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$UserModelCopyWithImpl<$Res, $Val extends UserModel>
|
||||
implements $UserModelCopyWith<$Res> {
|
||||
_$UserModelCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? email = null,
|
||||
Object? name = null,
|
||||
Object? avatarUrl = freezed,
|
||||
Object? token = null,
|
||||
Object? tokenExpiry = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
email: null == email
|
||||
? _value.email
|
||||
: email // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
name: null == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
avatarUrl: freezed == avatarUrl
|
||||
? _value.avatarUrl
|
||||
: avatarUrl // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
token: null == token
|
||||
? _value.token
|
||||
: token // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
tokenExpiry: freezed == tokenExpiry
|
||||
? _value.tokenExpiry
|
||||
: tokenExpiry // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$UserModelImplCopyWith<$Res>
|
||||
implements $UserModelCopyWith<$Res> {
|
||||
factory _$$UserModelImplCopyWith(
|
||||
_$UserModelImpl value, $Res Function(_$UserModelImpl) then) =
|
||||
__$$UserModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{String id,
|
||||
String email,
|
||||
String name,
|
||||
String? avatarUrl,
|
||||
String token,
|
||||
DateTime? tokenExpiry});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$UserModelImplCopyWithImpl<$Res>
|
||||
extends _$UserModelCopyWithImpl<$Res, _$UserModelImpl>
|
||||
implements _$$UserModelImplCopyWith<$Res> {
|
||||
__$$UserModelImplCopyWithImpl(
|
||||
_$UserModelImpl _value, $Res Function(_$UserModelImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? email = null,
|
||||
Object? name = null,
|
||||
Object? avatarUrl = freezed,
|
||||
Object? token = null,
|
||||
Object? tokenExpiry = freezed,
|
||||
}) {
|
||||
return _then(_$UserModelImpl(
|
||||
id: null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
email: null == email
|
||||
? _value.email
|
||||
: email // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
name: null == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
avatarUrl: freezed == avatarUrl
|
||||
? _value.avatarUrl
|
||||
: avatarUrl // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
token: null == token
|
||||
? _value.token
|
||||
: token // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
tokenExpiry: freezed == tokenExpiry
|
||||
? _value.tokenExpiry
|
||||
: tokenExpiry // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$UserModelImpl extends _UserModel {
|
||||
const _$UserModelImpl(
|
||||
{required this.id,
|
||||
required this.email,
|
||||
required this.name,
|
||||
this.avatarUrl,
|
||||
required this.token,
|
||||
this.tokenExpiry})
|
||||
: super._();
|
||||
|
||||
factory _$UserModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$UserModelImplFromJson(json);
|
||||
|
||||
@override
|
||||
final String id;
|
||||
@override
|
||||
final String email;
|
||||
@override
|
||||
final String name;
|
||||
@override
|
||||
final String? avatarUrl;
|
||||
@override
|
||||
final String token;
|
||||
@override
|
||||
final DateTime? tokenExpiry;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UserModel(id: $id, email: $email, name: $name, avatarUrl: $avatarUrl, token: $token, tokenExpiry: $tokenExpiry)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$UserModelImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.email, email) || other.email == email) &&
|
||||
(identical(other.name, name) || other.name == name) &&
|
||||
(identical(other.avatarUrl, avatarUrl) ||
|
||||
other.avatarUrl == avatarUrl) &&
|
||||
(identical(other.token, token) || other.token == token) &&
|
||||
(identical(other.tokenExpiry, tokenExpiry) ||
|
||||
other.tokenExpiry == tokenExpiry));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, id, email, name, avatarUrl, token, tokenExpiry);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$UserModelImplCopyWith<_$UserModelImpl> get copyWith =>
|
||||
__$$UserModelImplCopyWithImpl<_$UserModelImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$UserModelImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _UserModel extends UserModel {
|
||||
const factory _UserModel(
|
||||
{required final String id,
|
||||
required final String email,
|
||||
required final String name,
|
||||
final String? avatarUrl,
|
||||
required final String token,
|
||||
final DateTime? tokenExpiry}) = _$UserModelImpl;
|
||||
const _UserModel._() : super._();
|
||||
|
||||
factory _UserModel.fromJson(Map<String, dynamic> json) =
|
||||
_$UserModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
String get id;
|
||||
@override
|
||||
String get email;
|
||||
@override
|
||||
String get name;
|
||||
@override
|
||||
String? get avatarUrl;
|
||||
@override
|
||||
String get token;
|
||||
@override
|
||||
DateTime? get tokenExpiry;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$UserModelImplCopyWith<_$UserModelImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
29
lib/features/auth/data/models/user_model.g.dart
Normal file
29
lib/features/auth/data/models/user_model.g.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'user_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$UserModelImpl _$$UserModelImplFromJson(Map<String, dynamic> json) =>
|
||||
_$UserModelImpl(
|
||||
id: json['id'] as String,
|
||||
email: json['email'] as String,
|
||||
name: json['name'] as String,
|
||||
avatarUrl: json['avatarUrl'] as String?,
|
||||
token: json['token'] as String,
|
||||
tokenExpiry: json['tokenExpiry'] == null
|
||||
? null
|
||||
: DateTime.parse(json['tokenExpiry'] as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$UserModelImplToJson(_$UserModelImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'email': instance.email,
|
||||
'name': instance.name,
|
||||
'avatarUrl': instance.avatarUrl,
|
||||
'token': instance.token,
|
||||
'tokenExpiry': instance.tokenExpiry?.toIso8601String(),
|
||||
};
|
||||
Reference in New Issue
Block a user