79072322

Date: 2024-10-09 23:29:02
Score: 0.5
Natty:
Report link

The StateNotifier own a state variable, and I was using a private _state variable. So my change should be like:

class MyFormNotifier extends StateNotifier<MyFormState> {
  MyFormNotifier() : super(MyFormState());

  void setId(String id) {
    state = MyFormState(
      id: id,
      name: state.name, // Aqui estamos usando o estado atual
    );
  }

  void setName(String name) {
    state = MyFormState(
      id: state.id,
      name: name,
    );
  }
}
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Germano