associatedPickupRate method
Implementation
PickupRate? associatedPickupRate(QuotedRate rate, {bool lockPrice = false}) {
if (rates == null) {
throw MissingPropertyException.generate(toString(), 'rates');
}
filterFunction(PickupRate pickupRate) {
if (pickupRate.price == null) {
return false;
}
if (lockPrice) {
if (pickupRate.price != rate.price) {
return false;
}
}
if (pickupRate.carrier != null) {
if (rate.carrier != null) {
if (pickupRate.carrier != rate.carrier) {
return false;
}
}
}
if (pickupRate.service != null) {
if (rate.service != null) {
if (pickupRate.service != rate.service) {
return false;
}
}
}
return true;
}
try {
return rates!.firstWhere(filterFunction);
} on StateError {
return null;
}
}