我正在学习冻结的块,当我使用这个肘时不会发出新的状态。
class HomeCubit extends Cubit<HomeState> {
HomeCubit() : super(HomeState.init());
void addNewNoteButton() async {
emit(state.copyWith(
isOpenBottomSheet:true,
));
}
}
但是当我使用这个肘部时,会发出新的状态:
class HomeCubit extends Cubit<HomeState> {
HomeCubit() : super(HomeState.init());
void addNewNoteButton({required bool isOpenBottomSheet}) async {
emit(state.copyWith(
isOpenBottomSheet:isOpenBottomSheet,
));
}
}
状态代码是:
@freezed
abstract class HomeState with _$HomeState {
const factory HomeState({
required bool isOpenBottomSheet,
}) = AddNewNoteClicked;
factory HomeState.init() => HomeState(
isOpenBottomSheet: true,
);
}