check null safety

This commit is contained in:
tzw
2021-09-10 14:27:38 +06:30
parent a144c945b6
commit 7670779b03
57 changed files with 620 additions and 626 deletions

View File

@@ -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(