79201904

Date: 2024-11-19 02:13:48
Score: 0.5
Natty:
Report link

Tanks to Md. Yeasin Sheikh, i found a solution using ValueGetter, just updating the value inside copyWith methos like this

RegistrationState copyWith({
//change this
ValueGetter<DateTime?>? birthday, 
String? email,
String? password,
}) {  
    return RegistrationState(
        //and this
        birthday: birthday != null ? birthday() : this.birthday
        specialty: specialty ?? this.specialty,
        email: email ?? this.email,
    ); 
}

and then just calling it from cubit function like this

void updateBirthday(DateTime? birthday) {
    emit(state.copyWith(birthday: () => birthday));
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Erick Galván