Untitled

 avatar
unknown
dart
3 years ago
2.3 kB
2
Indexable
import 'package:iketfaa_delivery/App/Delivery/Models/Main/OrderAddress.dart';

class DriverOffer {
  double? rate;
  double? price, totalDistance;
  String? orderID,
      driverName,
      driverID,
      carYear,
      carPlate,
      offerID,
      mobileNumber;
  int? driverEstimateTime, carType, carModel, carClass;
  DateTime? date;
  OrderAddress? orderAddress;
  DriverOffer(
      {this.rate,
      this.offerID,
      this.orderID,
      this.price,
      this.totalDistance,
      this.driverName,
      this.driverID,
      this.driverEstimateTime,
      this.carYear,
      this.carPlate,
      this.carType,
      this.carModel,
      this.carClass,
      this.mobileNumber,
      this.orderAddress,
      this.date});

  DriverOffer.fromJson(Map<String, dynamic> json) {
    rate = json['rate'] == null ? null : json['rate'].toDouble();
    orderID = json['orderID'];
    offerID = json['offerID'];
    price = json['price'];
    totalDistance = json['totalDistance'];
    driverName = json['driverName'];
    driverID = json['driverID'];
    driverEstimateTime = json['driverEstimateTime'];
    carYear = json['carYear'];
    carPlate = json['carPlate'];
    carType = json['carType'];
    carModel = json['carModel'];
    carClass = json['carClass'];
    orderAddress =
        json['address'] == null ? null : OrderAddress.fromMap(json['address']);
    date = json['date'].toString().contains(':')
        ? json['date']
        : json['date'].toDate();
    mobileNumber = json['mobileNumber'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['rate'] = this.rate;
    data['offerID'] = this.offerID;
    data['orderID'] = this.orderID;
    data['price'] = this.price;
    data['totalDistance'] = this.totalDistance;
    data['driverName'] = this.driverName;
    data['driverID'] = this.driverID;
    data['driverEstimateTime'] = this.driverEstimateTime;
    data['carYear'] = this.carYear;
    data['carPlate'] = this.carPlate;
    data['carType'] = this.carType;
    data['carModel'] = this.carModel;
    data['carClass'] = this.carClass;
    data['date'] = this.date;
    data['address'] = this.orderAddress;
    data['mobileNumber'] = this.mobileNumber;
    return data;
  }
}