我正在将 bloc 与 dartz 和 freezed 库一起使用。我需要当用户点击保存数据时,所有输入字段恢复默认。但这并没有发生。
肘的代码是:
void addNewNoteButton() async {
if(state.note.input.isRight()) {
emit(state.copyWith(validToBeSavedToDB: true));
}
state.copyWith(note: Note( textInput: ''),radioValue: 1); //-> does not happened
}
状态码是:
@freezed
abstract class NoteFormState with _$NoteFormState {
const factory NoteFormState({
required int radioValue,
required Note note,
required bool validToBeSavedToDB,
}) = _NoteFormState;
factory NoteFormState.initial() => NoteFormState(
note: Note(textInput: ''),
radioValue: 1,
validToBeSavedToDB: false,);