check null safety
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||
|
||||
import 'cargo_type.dart';
|
||||
@@ -11,26 +10,25 @@ class Rate {
|
||||
double diffDiscountWeight;
|
||||
double diffWeightRate;
|
||||
|
||||
List<CargoType> cargoTypes;
|
||||
List<CargoType> customDuties;
|
||||
List<DiscountByWeight> discountByWeights;
|
||||
List<CargoType> cargoTypes = [];
|
||||
List<CargoType> customDuties = [];
|
||||
List<DiscountByWeight> discountByWeights = [];
|
||||
|
||||
DiscountByWeight getDiscountByWeight(double weight) {
|
||||
discountByWeights.sort((d1, d2) => d2.weight.compareTo(d1.weight));
|
||||
return discountByWeights.firstWhere((e) => e.weight < weight,
|
||||
orElse: () => null);
|
||||
return discountByWeights.firstWhere((e) => e.weight < weight);
|
||||
}
|
||||
|
||||
CargoType get defaultCargoType => cargoTypes == null
|
||||
CargoType? get defaultCargoType => cargoTypes == null
|
||||
? null
|
||||
: cargoTypes.firstWhere((e) => e.name == "General");
|
||||
|
||||
Rate(
|
||||
{this.deliveryFee,
|
||||
this.freeDeliveryWeight,
|
||||
this.volumetricRatio,
|
||||
this.diffDiscountWeight,
|
||||
this.diffWeightRate});
|
||||
{this.deliveryFee = 0,
|
||||
this.freeDeliveryWeight = 0,
|
||||
this.volumetricRatio = 0,
|
||||
this.diffDiscountWeight = 0,
|
||||
this.diffWeightRate = 0});
|
||||
|
||||
factory Rate.fromMap(Map<String, dynamic> map) {
|
||||
return Rate(
|
||||
|
||||
Reference in New Issue
Block a user