我正在使用冻结的集团。我从来没有给出state.isOpenBottomSheet
的值false
,尽管 else 会在state.inputTextValue.input.isRight()
发生时执行!
代码是:
if (state.isOpenBottomSheet) {
context
.read<HomeCubit>()
.addNewNoteButton(isOpenBottomSheet: true);
_scaffoldKey.currentState!
.showBottomSheet(
(context) => const AddNewNoteBottomSheet())
.closed
.then(
(_) => context
.read<HomeCubit>()
.addNewNoteButton(isOpenBottomSheet: true),
);
} else {
if (state.inputTextValue.input.isRight()) {
final DBHelper _dbHelper = DBHelper();
await _dbHelper.insertNodeToDB(
noteDatabaseModel: NoteDatabaseModel(
content: state.inputTextValue.input
.getOrElse(() => 'invalid note'),
status: state.radioValue,
),
);
}
}
国家代码:
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,
);
}