facility_booking_view_model.dart 829 B

123456789101112131415161718192021222324252627282930313233343536
  1. import 'package:riverpod_annotation/riverpod_annotation.dart';
  2. import 'package:shared/utils/log_utils.dart';
  3. import 'facility_booking_state.dart';
  4. part 'facility_booking_view_model.g.dart';
  5. @riverpod
  6. class FacilityBookingViewModel extends _$FacilityBookingViewModel {
  7. @override
  8. FacilityBookingState build() {
  9. final state = FacilityBookingState(selectedDate: DateTime.now());
  10. initListener(state);
  11. ref.onDispose(() {
  12. onDispose(state);
  13. });
  14. return state;
  15. }
  16. //修改选中的时间
  17. void changeSelectedDate(DateTime dateTime) {
  18. state = state.copyWith(selectedDate: dateTime);
  19. Log.d("当前选中的日期:$dateTime");
  20. }
  21. void initListener(FacilityBookingState state) {
  22. }
  23. void onDispose(FacilityBookingState state) {
  24. Log.d("FacilityBookingViewModel - onDispose");
  25. }
  26. }