initSearch method
Implementation
Future<void> initSearch() async {
if (Requests.box.hasData('hasSearch') &&
Requests.box.read('hasSearch') == true) {
tripType.value = Requests.box.read('searchType') == 'one_way'
? TripType.oneWay
: Requests.box.read('searchType') == 'round_trip'
? TripType.roundTrip
: TripType.multiCity;
tempTripType.value = tripType.value;
searchAdults.value = Requests.box.read('searchAdults');
searchChildren.value = Requests.box.read('searchChildren');
searchInfantsInSeats.value = Requests.box.read('searchInfantsInSeats');
searchInfantsInLap.value = Requests.box.read('searchInfantsInLap');
tempAdult.value = searchAdults.value;
tempChildren.value = searchChildren.value;
tempInfantsInSeats.value = searchInfantsInSeats.value;
tempInfantsInLap.value = searchInfantsInLap.value;
isFlexibleDeparture.value = Requests.box.read('searchFlexible');
searchDepartureDate.value = Requests.box.read('searchDeparture');
searchReturnDate.value = Requests.box.read('searchReturn');
searchClassIndex.value = Requests.box.read('searchClass');
searchFromAirport.value = FromAirport.fromJson(
Requests.box.read('searchFrom'),
);
var tmp = Requests.box.read('flightType');
flightType.value = (tmp == 'standard') ? FlightType.standard : (tmp == 'exclusive') ? FlightType.exclusive : FlightType.exclusivePlus;
tempFlightType.value = flightType.value;
searchToAirport.value = FromAirport.fromJson(
Requests.box.read('searchTo'),
);
allowedAdultPassengerLimit =
Requests.box.read('allowedAdultPassengerLimit');
_setStoredValueToTempChildrenFields();
}
searchCreditEarned.value = 0;
searchCreditUsed.value = 0;
fromAirportController.text =
'${searchFromAirport.value?.code ?? ''} - ${searchFromAirport.value?.name ?? ''}';
_fromAirPortListener();
toAirportController.text =
'${searchToAirport.value?.code ?? ''} - ${searchToAirport.value?.name ?? ''}';
_toAirPortListener();
if (authenticationController.isProfileLoaded.isFalse) {
ever(
authenticationController.isProfileLoaded,
(callback) {
loadTripsV3();
},
);
} else {
loadTripsV3();
}
}