check null safety
This commit is contained in:
@@ -4,35 +4,35 @@ import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/domain/vo/delivery_address.dart';
|
||||
|
||||
class Shipment {
|
||||
String id;
|
||||
String shipmentNumber;
|
||||
String shipmentType;
|
||||
DeliveryAddress pickupAddress;
|
||||
DateTime pickupDate;
|
||||
String pickupTimeStart;
|
||||
String pickupTimeEnd;
|
||||
String? id;
|
||||
String? shipmentNumber;
|
||||
String? shipmentType;
|
||||
DeliveryAddress? pickupAddress;
|
||||
DateTime? pickupDate;
|
||||
String? pickupTimeStart;
|
||||
String? pickupTimeEnd;
|
||||
|
||||
String userName;
|
||||
String userID;
|
||||
String phoneNumber;
|
||||
int numberOfPackage;
|
||||
int weight;
|
||||
double handlingFee;
|
||||
double paidHandlingFee;
|
||||
String address;
|
||||
String status;
|
||||
String? userName;
|
||||
String? userID;
|
||||
String? phoneNumber;
|
||||
int numberOfPackage = 0;
|
||||
int weight = 0;
|
||||
double handlingFee = 0;
|
||||
double paidHandlingFee = 0;
|
||||
String? address;
|
||||
String? status;
|
||||
bool isCourier;
|
||||
int radioIndex;
|
||||
List<Carton> boxes;
|
||||
|
||||
String pickupUserID;
|
||||
String pickupUserName;
|
||||
String pickupUserPhoneNumber;
|
||||
String? pickupUserID;
|
||||
String? pickupUserName;
|
||||
String? pickupUserPhoneNumber;
|
||||
|
||||
String fcsShipmentID;
|
||||
String fcsShipmentNumber;
|
||||
String shipmentLabelUrl;
|
||||
bool isSelected;
|
||||
String? fcsShipmentID;
|
||||
String? fcsShipmentNumber;
|
||||
String? shipmentLabelUrl;
|
||||
bool isSelected = false;
|
||||
|
||||
Shipment(
|
||||
{this.id,
|
||||
@@ -43,28 +43,28 @@ class Shipment {
|
||||
this.phoneNumber,
|
||||
this.pickupTimeStart,
|
||||
this.pickupTimeEnd,
|
||||
this.numberOfPackage,
|
||||
this.weight,
|
||||
this.handlingFee,
|
||||
this.paidHandlingFee,
|
||||
this.numberOfPackage = 0,
|
||||
this.weight = 0,
|
||||
this.handlingFee = 0,
|
||||
this.paidHandlingFee = 0,
|
||||
this.address,
|
||||
this.status,
|
||||
this.pickupDate,
|
||||
this.isCourier = false,
|
||||
this.radioIndex = 1,
|
||||
this.pickupAddress,
|
||||
required this.pickupAddress,
|
||||
this.pickupUserID,
|
||||
this.pickupUserName,
|
||||
this.pickupUserPhoneNumber,
|
||||
this.fcsShipmentID,
|
||||
this.fcsShipmentNumber,
|
||||
this.shipmentLabelUrl,
|
||||
this.boxes});
|
||||
this.boxes = const []});
|
||||
|
||||
int get last => DateTime.now().difference(pickupDate).inDays;
|
||||
// int get last => DateTime.now().difference(pickupDate).inDays;
|
||||
|
||||
double get totalWeight => boxes?.fold(0, (p, e) => p + e.actualWeight);
|
||||
int get totalCount => boxes?.length;
|
||||
double get totalWeight => boxes.fold(0, (p, e) => p + e.actualWeight);
|
||||
int get totalCount => boxes.length;
|
||||
|
||||
bool get isPending => status == shipment_pending_status;
|
||||
bool get isAssigned => status == shipment_assigned_status;
|
||||
@@ -100,15 +100,15 @@ class Shipment {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
List _boxes = boxes?.map((l) => l.toMap())?.toList() ?? [];
|
||||
List _boxes = boxes.map((l) => l.toMap()).toList();
|
||||
|
||||
return {
|
||||
"id": id,
|
||||
'user_id': userID,
|
||||
'cartons': _boxes,
|
||||
'shipment_type': shipmentType,
|
||||
'pickup_address': pickupAddress.toMap(),
|
||||
"pickup_date": pickupDate?.toUtc()?.toIso8601String(),
|
||||
'pickup_address': pickupAddress?.toMap(),
|
||||
"pickup_date": pickupDate?.toUtc().toIso8601String(),
|
||||
'pickup_time_start': pickupTimeStart,
|
||||
'pickup_time_end': pickupTimeEnd,
|
||||
'pickup_user_id': pickupUserID,
|
||||
|
||||
Reference in New Issue
Block a user