I would like to correct this error flutter bloc constant

36 views Asked by At

The default value of an optional parameter must be constant

abstract class LoginState {
    const LoginState();
}

class LoginInitialState extends LoginState {
    const LoginInitialState();
}

class LoginFinalState extends LoginState {
    final Usuario usuario;
    const LoginFinalState({this.usuario = const Usuario()});
    //The default value of an optional parameter must be constant.  
}
1

There are 1 answers

0
Zhentao On

you can remove all the const keyword, if you don't want do this, just add a cont constructor to Usuario like below

class Usuario {
  const Usuario();
}