use copywith and final class for bookableSpaceConfig

This commit is contained in:
Rafeek-Khoudare
2025-07-21 14:34:36 +03:00
parent 729b0caac3
commit b12903059d
4 changed files with 16 additions and 14 deletions

View File

@ -1,12 +1,12 @@
import 'package:flutter/material.dart';
class BookableSpaceConfig {
String configUuid;
List<String> bookableDays;
TimeOfDay? bookingStartTime;
TimeOfDay? bookingEndTime;
int cost;
bool availability;
final String configUuid;
final List<String> bookableDays;
final TimeOfDay? bookingStartTime;
final TimeOfDay? bookingEndTime;
final int cost;
final bool availability;
BookableSpaceConfig({
required this.configUuid,
required this.availability,

View File

@ -66,7 +66,8 @@ class BookingPeriodWidget extends StatelessWidget {
throw Exception();
} else {
setupBookableSpacesBloc.selectedBookableSpaces.forEach(
(e) => e.spaceConfig!.bookingStartTime = timePicked,
(e) =>
e.spaceConfig!.copyWith(bookingStartTime: timePicked),
);
}
},
@ -99,7 +100,8 @@ class BookingPeriodWidget extends StatelessWidget {
throw Exception();
} else {
setupBookableSpacesBloc.selectedBookableSpaces.forEach(
(e) => e.spaceConfig!.bookingEndTime = timePicked,
(e) =>
e.spaceConfig!.copyWith(bookingEndTime: timePicked),
);
}
},

View File

@ -81,7 +81,7 @@ class _PointsPartWidgetState extends State<PointsPartWidget> {
.read<SetupBookableSpacesBloc>()
.selectedBookableSpaces
.forEach(
(e) => e.spaceConfig!.cost = -1,
(e) => e.spaceConfig!.copyWith(cost: -1),
);
context
.read<SetupBookableSpacesBloc>()
@ -95,7 +95,7 @@ class _PointsPartWidgetState extends State<PointsPartWidget> {
.read<SetupBookableSpacesBloc>()
.selectedBookableSpaces
.forEach(
(e) => e.spaceConfig!.cost = 0,
(e) => e.spaceConfig!.copyWith(cost: 0),
);
context
.read<SetupBookableSpacesBloc>()
@ -118,10 +118,10 @@ class _PointsPartWidgetState extends State<PointsPartWidget> {
.read<SetupBookableSpacesBloc>()
.selectedBookableSpaces
.forEach(
(e) => e.spaceConfig!.cost = int.parse(
widget.pointsController.text.isEmpty
(e) => e.spaceConfig!.copyWith(
cost: int.parse(widget.pointsController.text.isEmpty
? '0'
: widget.pointsController.text,
: widget.pointsController.text),
),
);
context

View File

@ -60,7 +60,7 @@ class _WeekDaysCheckboxRowState extends State<WeekDaysCheckboxRow> {
for (var space in context
.read<SetupBookableSpacesBloc>()
.selectedBookableSpaces) {
space.spaceConfig!.bookableDays = selectedDays;
space.spaceConfig!.copyWith(bookableDays: selectedDays);
}
});