refactor(account): migrate personal_data to SfPhoneNumber and fix change_password state

This commit is contained in:
2026-04-15 17:06:46 +02:00
parent 56e437ff13
commit 648d0fc04b
7 changed files with 102 additions and 94 deletions

View File

@@ -53,7 +53,7 @@ class _NewPasswordSection extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final vm = ref.read(changePasswordViewModelProvider.notifier);
final showPassword = ref.watch(
changePasswordViewModelProvider.select((s) => s.showCurrentPassword),
changePasswordViewModelProvider.select((s) => s.showNewPassword),
);
return CustomTextField(
@@ -73,7 +73,7 @@ class _RepeatPasswordSection extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final vm = ref.read(changePasswordViewModelProvider.notifier);
final showPassword = ref.watch(
changePasswordViewModelProvider.select((s) => s.showCurrentPassword),
changePasswordViewModelProvider.select((s) => s.showRepeatedPassword),
);
return CustomTextField(

View File

@@ -43,10 +43,6 @@ class ChangePasswordViewModel extends Notifier<ChangePasswordViewState> {
ref.onDispose(disposeControllers);
}
void toggleCurrentPasswordVisibility() {
state = state.copyWith(showCurrentPassword: !state.showCurrentPassword);
}
void toggleNewPasswordVisibility() {
state = state.copyWith(showNewPassword: !state.showNewPassword);
}

View File

@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$ChangePasswordViewState {
bool get isLoading; bool get isComplete; bool get showCurrentPassword; bool get showNewPassword; bool get showRepeatedPassword; String get currentPassword; String get newPassword; String get repeatPassword; String get errorMessage;
bool get isLoading; bool get isComplete; bool get showNewPassword; bool get showRepeatedPassword; String get newPassword; String get repeatPassword; String get errorMessage;
/// Create a copy of ChangePasswordViewState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $ChangePasswordViewStateCopyWith<ChangePasswordViewState> get copyWith => _$Chan
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChangePasswordViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.showCurrentPassword, showCurrentPassword) || other.showCurrentPassword == showCurrentPassword)&&(identical(other.showNewPassword, showNewPassword) || other.showNewPassword == showNewPassword)&&(identical(other.showRepeatedPassword, showRepeatedPassword) || other.showRepeatedPassword == showRepeatedPassword)&&(identical(other.currentPassword, currentPassword) || other.currentPassword == currentPassword)&&(identical(other.newPassword, newPassword) || other.newPassword == newPassword)&&(identical(other.repeatPassword, repeatPassword) || other.repeatPassword == repeatPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
return identical(this, other) || (other.runtimeType == runtimeType&&other is ChangePasswordViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.showNewPassword, showNewPassword) || other.showNewPassword == showNewPassword)&&(identical(other.showRepeatedPassword, showRepeatedPassword) || other.showRepeatedPassword == showRepeatedPassword)&&(identical(other.newPassword, newPassword) || other.newPassword == newPassword)&&(identical(other.repeatPassword, repeatPassword) || other.repeatPassword == repeatPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showCurrentPassword,showNewPassword,showRepeatedPassword,currentPassword,newPassword,repeatPassword,errorMessage);
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showNewPassword,showRepeatedPassword,newPassword,repeatPassword,errorMessage);
@override
String toString() {
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showCurrentPassword: $showCurrentPassword, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, currentPassword: $currentPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
}
@@ -45,7 +45,7 @@ abstract mixin class $ChangePasswordViewStateCopyWith<$Res> {
factory $ChangePasswordViewStateCopyWith(ChangePasswordViewState value, $Res Function(ChangePasswordViewState) _then) = _$ChangePasswordViewStateCopyWithImpl;
@useResult
$Res call({
bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage
bool isLoading, bool isComplete, bool showNewPassword, bool showRepeatedPassword, String newPassword, String repeatPassword, String errorMessage
});
@@ -62,15 +62,13 @@ class _$ChangePasswordViewStateCopyWithImpl<$Res>
/// Create a copy of ChangePasswordViewState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isComplete = null,Object? showCurrentPassword = null,Object? showNewPassword = null,Object? showRepeatedPassword = null,Object? currentPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isComplete = null,Object? showNewPassword = null,Object? showRepeatedPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
return _then(_self.copyWith(
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
as bool,showCurrentPassword: null == showCurrentPassword ? _self.showCurrentPassword : showCurrentPassword // ignore: cast_nullable_to_non_nullable
as bool,showNewPassword: null == showNewPassword ? _self.showNewPassword : showNewPassword // ignore: cast_nullable_to_non_nullable
as bool,showRepeatedPassword: null == showRepeatedPassword ? _self.showRepeatedPassword : showRepeatedPassword // ignore: cast_nullable_to_non_nullable
as bool,currentPassword: null == currentPassword ? _self.currentPassword : currentPassword // ignore: cast_nullable_to_non_nullable
as String,newPassword: null == newPassword ? _self.newPassword : newPassword // ignore: cast_nullable_to_non_nullable
as bool,newPassword: null == newPassword ? _self.newPassword : newPassword // ignore: cast_nullable_to_non_nullable
as String,repeatPassword: null == repeatPassword ? _self.repeatPassword : repeatPassword // ignore: cast_nullable_to_non_nullable
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String,
@@ -158,10 +156,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, bool showNewPassword, bool showRepeatedPassword, String newPassword, String repeatPassword, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ChangePasswordViewState() when $default != null:
return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that.showNewPassword,_that.showRepeatedPassword,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
return $default(_that.isLoading,_that.isComplete,_that.showNewPassword,_that.showRepeatedPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
return orElse();
}
@@ -179,10 +177,10 @@ return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, bool showNewPassword, bool showRepeatedPassword, String newPassword, String repeatPassword, String errorMessage) $default,) {final _that = this;
switch (_that) {
case _ChangePasswordViewState():
return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that.showNewPassword,_that.showRepeatedPassword,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
return $default(_that.isLoading,_that.isComplete,_that.showNewPassword,_that.showRepeatedPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
throw StateError('Unexpected subclass');
}
@@ -199,10 +197,10 @@ return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isComplete, bool showNewPassword, bool showRepeatedPassword, String newPassword, String repeatPassword, String errorMessage)? $default,) {final _that = this;
switch (_that) {
case _ChangePasswordViewState() when $default != null:
return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that.showNewPassword,_that.showRepeatedPassword,_that.currentPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
return $default(_that.isLoading,_that.isComplete,_that.showNewPassword,_that.showRepeatedPassword,_that.newPassword,_that.repeatPassword,_that.errorMessage);case _:
return null;
}
@@ -214,15 +212,13 @@ return $default(_that.isLoading,_that.isComplete,_that.showCurrentPassword,_that
class _ChangePasswordViewState implements ChangePasswordViewState {
const _ChangePasswordViewState({this.isLoading = false, this.isComplete = false, this.showCurrentPassword = false, this.showNewPassword = false, this.showRepeatedPassword = false, this.currentPassword = '', this.newPassword = '', this.repeatPassword = '', this.errorMessage = ''});
const _ChangePasswordViewState({this.isLoading = false, this.isComplete = false, this.showNewPassword = false, this.showRepeatedPassword = false, this.newPassword = '', this.repeatPassword = '', this.errorMessage = ''});
@override@JsonKey() final bool isLoading;
@override@JsonKey() final bool isComplete;
@override@JsonKey() final bool showCurrentPassword;
@override@JsonKey() final bool showNewPassword;
@override@JsonKey() final bool showRepeatedPassword;
@override@JsonKey() final String currentPassword;
@override@JsonKey() final String newPassword;
@override@JsonKey() final String repeatPassword;
@override@JsonKey() final String errorMessage;
@@ -237,16 +233,16 @@ _$ChangePasswordViewStateCopyWith<_ChangePasswordViewState> get copyWith => __$C
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChangePasswordViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.showCurrentPassword, showCurrentPassword) || other.showCurrentPassword == showCurrentPassword)&&(identical(other.showNewPassword, showNewPassword) || other.showNewPassword == showNewPassword)&&(identical(other.showRepeatedPassword, showRepeatedPassword) || other.showRepeatedPassword == showRepeatedPassword)&&(identical(other.currentPassword, currentPassword) || other.currentPassword == currentPassword)&&(identical(other.newPassword, newPassword) || other.newPassword == newPassword)&&(identical(other.repeatPassword, repeatPassword) || other.repeatPassword == repeatPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChangePasswordViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.showNewPassword, showNewPassword) || other.showNewPassword == showNewPassword)&&(identical(other.showRepeatedPassword, showRepeatedPassword) || other.showRepeatedPassword == showRepeatedPassword)&&(identical(other.newPassword, newPassword) || other.newPassword == newPassword)&&(identical(other.repeatPassword, repeatPassword) || other.repeatPassword == repeatPassword)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showCurrentPassword,showNewPassword,showRepeatedPassword,currentPassword,newPassword,repeatPassword,errorMessage);
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,showNewPassword,showRepeatedPassword,newPassword,repeatPassword,errorMessage);
@override
String toString() {
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showCurrentPassword: $showCurrentPassword, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, currentPassword: $currentPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
return 'ChangePasswordViewState(isLoading: $isLoading, isComplete: $isComplete, showNewPassword: $showNewPassword, showRepeatedPassword: $showRepeatedPassword, newPassword: $newPassword, repeatPassword: $repeatPassword, errorMessage: $errorMessage)';
}
@@ -257,7 +253,7 @@ abstract mixin class _$ChangePasswordViewStateCopyWith<$Res> implements $ChangeP
factory _$ChangePasswordViewStateCopyWith(_ChangePasswordViewState value, $Res Function(_ChangePasswordViewState) _then) = __$ChangePasswordViewStateCopyWithImpl;
@override @useResult
$Res call({
bool isLoading, bool isComplete, bool showCurrentPassword, bool showNewPassword, bool showRepeatedPassword, String currentPassword, String newPassword, String repeatPassword, String errorMessage
bool isLoading, bool isComplete, bool showNewPassword, bool showRepeatedPassword, String newPassword, String repeatPassword, String errorMessage
});
@@ -274,15 +270,13 @@ class __$ChangePasswordViewStateCopyWithImpl<$Res>
/// Create a copy of ChangePasswordViewState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isComplete = null,Object? showCurrentPassword = null,Object? showNewPassword = null,Object? showRepeatedPassword = null,Object? currentPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isComplete = null,Object? showNewPassword = null,Object? showRepeatedPassword = null,Object? newPassword = null,Object? repeatPassword = null,Object? errorMessage = null,}) {
return _then(_ChangePasswordViewState(
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
as bool,showCurrentPassword: null == showCurrentPassword ? _self.showCurrentPassword : showCurrentPassword // ignore: cast_nullable_to_non_nullable
as bool,showNewPassword: null == showNewPassword ? _self.showNewPassword : showNewPassword // ignore: cast_nullable_to_non_nullable
as bool,showRepeatedPassword: null == showRepeatedPassword ? _self.showRepeatedPassword : showRepeatedPassword // ignore: cast_nullable_to_non_nullable
as bool,currentPassword: null == currentPassword ? _self.currentPassword : currentPassword // ignore: cast_nullable_to_non_nullable
as String,newPassword: null == newPassword ? _self.newPassword : newPassword // ignore: cast_nullable_to_non_nullable
as bool,newPassword: null == newPassword ? _self.newPassword : newPassword // ignore: cast_nullable_to_non_nullable
as String,repeatPassword: null == repeatPassword ? _self.repeatPassword : repeatPassword // ignore: cast_nullable_to_non_nullable
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String,

View File

@@ -24,7 +24,7 @@ class PersonalDataScreen extends ConsumerWidget {
if (errorMessage.isNotEmpty) {
showTopSnackbar(
context,
message: errorMessage,
message: context.translate(errorMessage),
type: MessageType.error,
);
}
@@ -169,8 +169,8 @@ class _PhoneField extends ConsumerWidget {
final hint = ref.watch(
personalDataViewModelProvider.select((s) => s.user?.phone ?? ''),
);
final dialCode = ref.read(
personalDataViewModelProvider.select((s) => s.dialCode),
final isoCode = ref.watch(
personalDataViewModelProvider.select((s) => s.isoCode),
);
return Row(
@@ -178,9 +178,10 @@ class _PhoneField extends ConsumerWidget {
children: [
CountryPrefixPicker(
headerText: context.translate(I18n.selectYourCountry),
initialSelection: dialCode,
initialSelection: isoCode,
onChanged: (country) {
vm.updateDialCode(country.dialCode ?? dialCode);
final code = country.code;
if (code != null) vm.updateCountry(code);
},
width: 80,
),

View File

@@ -4,6 +4,7 @@ import 'package:account/src/features/personal_data/domain/entities/update_user_r
import 'package:account/src/features/personal_data/presentation/state/personal_data_view_state.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:sf_localizations/sf_localizations.dart';
import 'package:sf_shared/sf_shared.dart';
import 'package:sf_tracking/sf_tracking.dart';
@@ -40,14 +41,28 @@ class PersonalDataViewModel extends Notifier<PersonalDataViewState> {
}
Future<void> _init() async {
final user = await ref.read(userInfoProvider.future);
state = state.copyWith(user: user, isLoading: false);
try {
final user = await ref.read(userInfoProvider.future);
if (!ref.mounted) return;
final parsed = SfPhoneNumber.tryParse(user.phone);
state = state.copyWith(
user: user,
isoCode: parsed?.isoCode ?? SfPhoneNumber.defaultIsoCode,
isLoading: false,
);
} catch (_) {
if (!ref.mounted) return;
state = state.copyWith(
isLoading: false,
errorMessage: I18n.errorGeneric,
);
}
}
void updateDialCode(String value) {
if (value == state.dialCode) return;
state = state.copyWith(dialCode: value, errorMessage: '');
void updateCountry(String isoCode) {
if (isoCode == state.isoCode) return;
state = state.copyWith(isoCode: isoCode, errorMessage: '');
}
bool get _hasChanges =>
@@ -55,25 +70,22 @@ class PersonalDataViewModel extends Notifier<PersonalDataViewState> {
lastNameController.text.trim().isNotEmpty ||
phoneController.text.trim().isNotEmpty;
UpdateUserRequestEntity _toRequest() {
final dialCode = state.dialCode;
final fullPhone = phoneController.text.trim().isNotEmpty
? dialCode + phoneController.text.trim()
: null;
return UpdateUserRequestEntity(
firstName: firstNameController.text.trim().isNotEmpty
? firstNameController.text.trim()
: null,
lastName: lastNameController.text.trim().isNotEmpty
? lastNameController.text.trim()
: null,
phone: fullPhone,
);
}
Future<void> updateUser() async {
if (state.isLoading || !_hasChanges) return;
final user = state.user;
if (user == null || state.isLoading || !_hasChanges) return;
String? fullPhone;
if (phoneController.text.trim().isNotEmpty) {
final parsed = SfPhoneNumber.tryParse(
phoneController.text,
defaultIsoCode: state.isoCode,
);
if (parsed == null) {
state = state.copyWith(errorMessage: I18n.errorMessagePhoneIsInvalid);
return;
}
fullPhone = parsed.e164;
}
try {
state = state.copyWith(
@@ -82,30 +94,35 @@ class PersonalDataViewModel extends Notifier<PersonalDataViewState> {
errorMessage: '',
);
final request = _toRequest();
await _usersRepository.updateUser(
userId: state.user!.id,
request: request,
final request = UpdateUserRequestEntity(
firstName: firstNameController.text.trim().isNotEmpty
? firstNameController.text.trim()
: null,
lastName: lastNameController.text.trim().isNotEmpty
? lastNameController.text.trim()
: null,
phone: fullPhone,
);
await _usersRepository.updateUser(userId: user.id, request: request);
if (!ref.mounted) return;
final updatedUser = state.user!.copyWith(
firstName: request.firstName ?? state.user!.firstName,
lastName: request.lastName ?? state.user!.lastName,
phone: request.phone ?? state.user!.phone,
final updatedUser = user.copyWith(
firstName: request.firstName ?? user.firstName,
lastName: request.lastName ?? user.lastName,
phone: request.phone ?? user.phone,
);
ref.read(userInfoProvider.notifier).setUser(updatedUser);
unawaited(_tracking.legacyAccountPersonalDataEdited());
state = state.copyWith(isLoading: false, isComplete: true);
} catch (e) {
} catch (_) {
if (!ref.mounted) return;
state = state.copyWith(
isLoading: false,
isComplete: false,
errorMessage: e.toString(),
errorMessage: I18n.errorGeneric,
);
}
}

View File

@@ -8,7 +8,7 @@ abstract class PersonalDataViewState with _$PersonalDataViewState {
const factory PersonalDataViewState({
@Default(true) bool isLoading,
@Default(false) bool isComplete,
@Default('+34') String dialCode,
@Default('ES') String isoCode,
UserEntity? user,
@Default('') String errorMessage,
}) = _PersonalDataViewState;

View File

@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$PersonalDataViewState {
bool get isLoading; bool get isComplete; String get dialCode; UserEntity? get user; String get errorMessage;
bool get isLoading; bool get isComplete; String get isoCode; UserEntity? get user; String get errorMessage;
/// Create a copy of PersonalDataViewState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $PersonalDataViewStateCopyWith<PersonalDataViewState> get copyWith => _$Personal
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is PersonalDataViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.user, user) || other.user == user)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
return identical(this, other) || (other.runtimeType == runtimeType&&other is PersonalDataViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.isoCode, isoCode) || other.isoCode == isoCode)&&(identical(other.user, user) || other.user == user)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,dialCode,user,errorMessage);
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,isoCode,user,errorMessage);
@override
String toString() {
return 'PersonalDataViewState(isLoading: $isLoading, isComplete: $isComplete, dialCode: $dialCode, user: $user, errorMessage: $errorMessage)';
return 'PersonalDataViewState(isLoading: $isLoading, isComplete: $isComplete, isoCode: $isoCode, user: $user, errorMessage: $errorMessage)';
}
@@ -45,7 +45,7 @@ abstract mixin class $PersonalDataViewStateCopyWith<$Res> {
factory $PersonalDataViewStateCopyWith(PersonalDataViewState value, $Res Function(PersonalDataViewState) _then) = _$PersonalDataViewStateCopyWithImpl;
@useResult
$Res call({
bool isLoading, bool isComplete, String dialCode, UserEntity? user, String errorMessage
bool isLoading, bool isComplete, String isoCode, UserEntity? user, String errorMessage
});
@@ -62,11 +62,11 @@ class _$PersonalDataViewStateCopyWithImpl<$Res>
/// Create a copy of PersonalDataViewState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isComplete = null,Object? dialCode = null,Object? user = freezed,Object? errorMessage = null,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isComplete = null,Object? isoCode = null,Object? user = freezed,Object? errorMessage = null,}) {
return _then(_self.copyWith(
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
as bool,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
as bool,isoCode: null == isoCode ? _self.isoCode : isoCode // ignore: cast_nullable_to_non_nullable
as String,user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
as UserEntity?,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String,
@@ -166,10 +166,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, String dialCode, UserEntity? user, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, String isoCode, UserEntity? user, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _PersonalDataViewState() when $default != null:
return $default(_that.isLoading,_that.isComplete,_that.dialCode,_that.user,_that.errorMessage);case _:
return $default(_that.isLoading,_that.isComplete,_that.isoCode,_that.user,_that.errorMessage);case _:
return orElse();
}
@@ -187,10 +187,10 @@ return $default(_that.isLoading,_that.isComplete,_that.dialCode,_that.user,_that
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, String dialCode, UserEntity? user, String errorMessage) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isComplete, String isoCode, UserEntity? user, String errorMessage) $default,) {final _that = this;
switch (_that) {
case _PersonalDataViewState():
return $default(_that.isLoading,_that.isComplete,_that.dialCode,_that.user,_that.errorMessage);case _:
return $default(_that.isLoading,_that.isComplete,_that.isoCode,_that.user,_that.errorMessage);case _:
throw StateError('Unexpected subclass');
}
@@ -207,10 +207,10 @@ return $default(_that.isLoading,_that.isComplete,_that.dialCode,_that.user,_that
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isComplete, String dialCode, UserEntity? user, String errorMessage)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isComplete, String isoCode, UserEntity? user, String errorMessage)? $default,) {final _that = this;
switch (_that) {
case _PersonalDataViewState() when $default != null:
return $default(_that.isLoading,_that.isComplete,_that.dialCode,_that.user,_that.errorMessage);case _:
return $default(_that.isLoading,_that.isComplete,_that.isoCode,_that.user,_that.errorMessage);case _:
return null;
}
@@ -222,12 +222,12 @@ return $default(_that.isLoading,_that.isComplete,_that.dialCode,_that.user,_that
class _PersonalDataViewState implements PersonalDataViewState {
const _PersonalDataViewState({this.isLoading = true, this.isComplete = false, this.dialCode = '+34', this.user, this.errorMessage = ''});
const _PersonalDataViewState({this.isLoading = true, this.isComplete = false, this.isoCode = 'ES', this.user, this.errorMessage = ''});
@override@JsonKey() final bool isLoading;
@override@JsonKey() final bool isComplete;
@override@JsonKey() final String dialCode;
@override@JsonKey() final String isoCode;
@override final UserEntity? user;
@override@JsonKey() final String errorMessage;
@@ -241,16 +241,16 @@ _$PersonalDataViewStateCopyWith<_PersonalDataViewState> get copyWith => __$Perso
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _PersonalDataViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.user, user) || other.user == user)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _PersonalDataViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isComplete, isComplete) || other.isComplete == isComplete)&&(identical(other.isoCode, isoCode) || other.isoCode == isoCode)&&(identical(other.user, user) || other.user == user)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,dialCode,user,errorMessage);
int get hashCode => Object.hash(runtimeType,isLoading,isComplete,isoCode,user,errorMessage);
@override
String toString() {
return 'PersonalDataViewState(isLoading: $isLoading, isComplete: $isComplete, dialCode: $dialCode, user: $user, errorMessage: $errorMessage)';
return 'PersonalDataViewState(isLoading: $isLoading, isComplete: $isComplete, isoCode: $isoCode, user: $user, errorMessage: $errorMessage)';
}
@@ -261,7 +261,7 @@ abstract mixin class _$PersonalDataViewStateCopyWith<$Res> implements $PersonalD
factory _$PersonalDataViewStateCopyWith(_PersonalDataViewState value, $Res Function(_PersonalDataViewState) _then) = __$PersonalDataViewStateCopyWithImpl;
@override @useResult
$Res call({
bool isLoading, bool isComplete, String dialCode, UserEntity? user, String errorMessage
bool isLoading, bool isComplete, String isoCode, UserEntity? user, String errorMessage
});
@@ -278,11 +278,11 @@ class __$PersonalDataViewStateCopyWithImpl<$Res>
/// Create a copy of PersonalDataViewState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isComplete = null,Object? dialCode = null,Object? user = freezed,Object? errorMessage = null,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isComplete = null,Object? isoCode = null,Object? user = freezed,Object? errorMessage = null,}) {
return _then(_PersonalDataViewState(
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,isComplete: null == isComplete ? _self.isComplete : isComplete // ignore: cast_nullable_to_non_nullable
as bool,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
as bool,isoCode: null == isoCode ? _self.isoCode : isoCode // ignore: cast_nullable_to_non_nullable
as String,user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
as UserEntity?,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String,