reloadBookingById method

void reloadBookingById(
  1. String bookingId
)

Implementation

void reloadBookingById(String bookingId) async {
  var response = await Requests.getDio().get("booking/$bookingId");
  // log("reload booking by id $response");
  if (response.statusCode == 200) {
    final index = bookingHistory.value.bookingsList
        ?.indexWhere((booking) => booking.id == bookingId);
    if (index != null) {
      bookingHistory.value.bookingsList?[index] =
          BookingHistory.fromJson(response.data['data']);
      bookingHistory.refresh();
    }
  } else {
    CustomFlashWidget.showFlashMessage(
      type: FlashType.error,
      title: "Failure",
      message:
          "Error while fetching the booking requests. Please try again later!",
    );
  }
}