Home > Mobile >  json response with model not returns any data flutter
json response with model not returns any data flutter

Time:12-16

So i am trying to retrieve json to a model,but i am getting response but when pass the response.body it shows nothing and it throws error but i am not sure what is wrong,when i try to debug this but it doesn't show anything and i have put this in try catch it shows

Invalid argument(s) (input): Must not be null error

Function for fetch data

var response = await http.get(Uri.parse(url), headers: {
      "Content-Type": "application/json",
      "Authorization": "Bearer $tokenData",
      "Accept": "application/json"
    });

    print('GetWorkingLists Response status: ${response.statusCode}');
    print('GetWorkingLists Response body: ${response.body}');
    setState(() {
      final deleteModel = deleteModelFromJson(response.body);
      print(deleteModel.data.vehicleRegisters.data[0].registerNumber);
    });

json response

{
    "success": true,
    "message": "",
    "data": {
        "vehicle_registers": {
            "current_page": 1,
            "data": [
                {
                    "id": 828,
                    "station_id": 3,
                    "branch_id": 43,
                    "manager_id": null,
                    "employee_id": null,
                    "created_by": 43,
                    "vehicle_id": 126,
                    "customer_name": "Test 31",
                    "mobile": "156656516",
                    "location": "loction",
                    "register_number": "KL12",
                    "working_status_id": 2,
                    "working_status_created_at": "2021-12-15 12:05:00",
                    "remarks": null,
                    "amount": "700.00",
                    "extra_amount": "0.00",
                    "discount": "0.00",
                    "total_amount": "700.00",
                    "suggestion": "test",
                    "inspection_comment": "test",
                    "feedback": null,
                    "app_or_web": 2,
                    "created_at": "15-12-2021 11:44 am",
                    "updated_at": "2021-12-15 12:05:00",
                    "deleted_at": null,
                    "working_status": {
                        "id": 2,
                        "name": "Work completed"
                    },
                    "vehicle": {
                        "id": 126,
                        "name": "Hyundai Creta"
                    },
                    "vehicle_registers_services": [
                        {
                            "id": 2317,
                            "vehicle_registers_id": 828,
                            "service_type_id": 1,
                            "service_type": {
                                "id": 1,
                                "name": "Car Wash"
                            },
                            "vehicle_types_serives_prices": {
                                "service_type_id": 1,
                                "price": "200.00"
                            }
                        },
                        {
                            "id": 2318,
                            "vehicle_registers_id": 828,
                            "service_type_id": 2,
                            "service_type": {
                                "id": 2,
                                "name": "Full Body Wash"
                            },
                            "vehicle_types_serives_prices": {
                                "service_type_id": 2,
                                "price": "500.00"
                            }
                        }
                    ],
                    "vehicle_registers_accessories": [],
                    "vehicle_registers_statuses": [
                        {
                            "id": 1618,
                            "vehicle_registers_id": 828,
                            "working_status_id": 0,
                            "created_at": "15-12-2021 11:44 am",
                            "working_status": {
                                "id": 0,
                                "name": "Registered"
                            }
                        },
                        {
                            "id": 1619,
                            "vehicle_registers_id": 828,
                            "working_status_id": 1,
                            "created_at": "15-12-2021 11:44 am",
                            "working_status": {
                                "id": 1,
                                "name": "Work started"
                            }
                        },
                        {
                            "id": 1620,
                            "vehicle_registers_id": 828,
                            "working_status_id": 2,
                            "created_at": "15-12-2021 12:05 pm",
                            "working_status": {
                                "id": 2,
                                "name": "Work completed"
                            }
                        }
                    ],
                    "vehicle_registers_used_stocks": [
                        {
                            "id": 16,
                            "vehicle_registers_id": 828,
                            "stocks_station_id": 31,
                            "station_id": 3,
                            "branch_id": 43,
                            "stock_id": 11,
                            "unit": 1,
                            "kg": 10,
                            "gm": 5,
                            "ltr": 0,
                            "ml": 0,
                            "counter": 0,
                            "created_at": "2021-12-15 12:05:00",
                            "updated_at": null,
                            "deleted_at": null,
                            "stocks_station": {
                                "id": 31,
                                "stock_id": 11,
                                "station_id": 3,
                                "branch_id": 43,
                                "kg": 0,
                                "gm": 0,
                                "ltr": 0,
                                "ml": 0,
                                "counter": 0,
                                "created_at": "2021-12-14 10:50:06",
                                "updated_at": "2021-12-15 12:05:00",
                                "deleted_at": null,
                                "stock": {
                                    "id": 11,
                                    "station_id": 3,
                                    "name": "Soap Powder",
                                    "unit": 1,
                                    "stock_date": "2021-12-14",
                                    "created_at": "2021-12-07 16:28:42",
                                    "updated_at": "2021-12-14 10:50:06",
                                    "deleted_at": null
                                }
                            }
                        }
                    ],
                    "service_station": {
                        "id": 3,
                        "name": "Station 01"
                    },
                    "employee": null,
                    "created_byy": {
                        "id": 43,
                        "name": "Branch1"
                    }
                }
            ],
            "first_page_url": "http:\/\/165.22.222.162\/api\/vehicle-register?page=1",
            "from": 1,
            "last_page": 1,
            "last_page_url": "http:\/\/165.22.222.162\/api\/vehicle-register?page=1",
            "next_page_url": null,
            "path": "http:\/\/165.22.222.162\/api\/vehicle-register",
            "per_page": 10,
            "prev_page_url": null,
            "to": 1,
            "total": 1
        },
        "total_amount": 700
    }
}

Model

// To parse this JSON data, do
//
//     final deleteModel = deleteModelFromJson(jsonString);

import 'dart:convert';

DeleteModel deleteModelFromJson(String str) => DeleteModel.fromJson(json.decode(str));

String deleteModelToJson(DeleteModel data) => json.encode(data.toJson());

class DeleteModel {
  DeleteModel({
    this.success,
    this.message,
    this.data,
  });

  bool success;
  String message;
  Data data;

  factory DeleteModel.fromJson(Map<String, dynamic> json) => DeleteModel(
    success: json["success"],
    message: json["message"],
    data: Data.fromJson(json["data"]),
  );

  Map<String, dynamic> toJson() => {
    "success": success,
    "message": message,
    "data": data.toJson(),
  };
}

class Data {
  Data({
    this.vehicleRegisters,
    this.totalAmount,
  });

  VehicleRegisters vehicleRegisters;
  int totalAmount;

  factory Data.fromJson(Map<String, dynamic> json) => Data(
    vehicleRegisters: VehicleRegisters.fromJson(json["vehicle_registers"]),
    totalAmount: json["total_amount"],
  );

  Map<String, dynamic> toJson() => {
    "vehicle_registers": vehicleRegisters.toJson(),
    "total_amount": totalAmount,
  };
}

class VehicleRegisters {
  VehicleRegisters({
    this.currentPage,
    this.data,
    this.firstPageUrl,
    this.from,
    this.lastPage,
    this.lastPageUrl,
    this.nextPageUrl,
    this.path,
    this.perPage,
    this.prevPageUrl,
    this.to,
    this.total,
  });

  int currentPage;
  List<Datum> data;
  String firstPageUrl;
  int from;
  int lastPage;
  String lastPageUrl;
  dynamic nextPageUrl;
  String path;
  int perPage;
  dynamic prevPageUrl;
  int to;
  int total;

  factory VehicleRegisters.fromJson(Map<String, dynamic> json) => VehicleRegisters(
    currentPage: json["current_page"],
    data: List<Datum>.from(json["data"].map((x) => Datum.fromJson(x))),
    firstPageUrl: json["first_page_url"],
    from: json["from"],
    lastPage: json["last_page"],
    lastPageUrl: json["last_page_url"],
    nextPageUrl: json["next_page_url"],
    path: json["path"],
    perPage: json["per_page"],
    prevPageUrl: json["prev_page_url"],
    to: json["to"],
    total: json["total"],
  );

  Map<String, dynamic> toJson() => {
    "current_page": currentPage,
    "data": List<dynamic>.from(data.map((x) => x.toJson())),
    "first_page_url": firstPageUrl,
    "from": from,
    "last_page": lastPage,
    "last_page_url": lastPageUrl,
    "next_page_url": nextPageUrl,
    "path": path,
    "per_page": perPage,
    "prev_page_url": prevPageUrl,
    "to": to,
    "total": total,
  };
}

class Datum {
  Datum({
    this.id,
    this.stationId,
    this.branchId,
    this.managerId,
    this.employeeId,
    this.createdBy,
    this.vehicleId,
    this.customerName,
    this.mobile,
    this.location,
    this.registerNumber,
    this.workingStatusId,
    this.workingStatusCreatedAt,
    this.remarks,
    this.amount,
    this.extraAmount,
    this.discount,
    this.totalAmount,
    this.suggestion,
    this.inspectionComment,
    this.feedback,
    this.appOrWeb,
    this.createdAt,
    this.updatedAt,
    this.deletedAt,
    this.workingStatus,
    this.vehicle,
    this.vehicleRegistersServices,
    this.vehicleRegistersAccessories,
    this.vehicleRegistersStatuses,
    this.vehicleRegistersUsedStocks,
    this.serviceStation,
    this.employee,
    this.createdByy,
  });

  int id;
  int stationId;
  int branchId;
  dynamic managerId;
  dynamic employeeId;
  int createdBy;
  int vehicleId;
  String customerName;
  String mobile;
  String location;
  String registerNumber;
  int workingStatusId;
  DateTime workingStatusCreatedAt;
  dynamic remarks;
  String amount;
  String extraAmount;
  String discount;
  String totalAmount;
  String suggestion;
  String inspectionComment;
  dynamic feedback;
  int appOrWeb;
  String createdAt;
  DateTime updatedAt;
  dynamic deletedAt;
  CreatedByy workingStatus;
  CreatedByy vehicle;
  List<VehicleRegistersService> vehicleRegistersServices;
  List<dynamic> vehicleRegistersAccessories;
  List<VehicleRegistersStatus> vehicleRegistersStatuses;
  List<VehicleRegistersUsedStock> vehicleRegistersUsedStocks;
  CreatedByy serviceStation;
  dynamic employee;
  CreatedByy createdByy;

  factory Datum.fromJson(Map<String, dynamic> json) => Datum(
    id: json["id"],
    stationId: json["station_id"],
    branchId: json["branch_id"],
    managerId: json["manager_id"],
    employeeId: json["employee_id"],
    createdBy: json["created_by"],
    vehicleId: json["vehicle_id"],
    customerName: json["customer_name"],
    mobile: json["mobile"],
    location: json["location"],
    registerNumber: json["register_number"],
    workingStatusId: json["working_status_id"],
    workingStatusCreatedAt: DateTime.parse(json["working_status_created_at"]),
    remarks: json["remarks"],
    amount: json["amount"],
    extraAmount: json["extra_amount"],
    discount: json["discount"],
    totalAmount: json["total_amount"],
    suggestion: json["suggestion"],
    inspectionComment: json["inspection_comment"],
    feedback: json["feedback"],
    appOrWeb: json["app_or_web"],
    createdAt: json["created_at"],
    updatedAt: DateTime.parse(json["updated_at"]),
    deletedAt: json["deleted_at"],
    workingStatus: CreatedByy.fromJson(json["working_status"]),
    vehicle: CreatedByy.fromJson(json["vehicle"]),
    vehicleRegistersServices: List<VehicleRegistersService>.from(json["vehicle_registers_services"].map((x) => VehicleRegistersService.fromJson(x))),
    vehicleRegistersAccessories: List<dynamic>.from(json["vehicle_registers_accessories"].map((x) => x)),
    vehicleRegistersStatuses: List<VehicleRegistersStatus>.from(json["vehicle_registers_statuses"].map((x) => VehicleRegistersStatus.fromJson(x))),
    vehicleRegistersUsedStocks: List<VehicleRegistersUsedStock>.from(json["vehicle_registers_used_stocks"].map((x) => VehicleRegistersUsedStock.fromJson(x))),
    serviceStation: CreatedByy.fromJson(json["service_station"]),
    employee: json["employee"],
    createdByy: CreatedByy.fromJson(json["created_byy"]),
  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "station_id": stationId,
    "branch_id": branchId,
    "manager_id": managerId,
    "employee_id": employeeId,
    "created_by": createdBy,
    "vehicle_id": vehicleId,
    "customer_name": customerName,
    "mobile": mobile,
    "location": location,
    "register_number": registerNumber,
    "working_status_id": workingStatusId,
    "working_status_created_at": workingStatusCreatedAt.toIso8601String(),
    "remarks": remarks,
    "amount": amount,
    "extra_amount": extraAmount,
    "discount": discount,
    "total_amount": totalAmount,
    "suggestion": suggestion,
    "inspection_comment": inspectionComment,
    "feedback": feedback,
    "app_or_web": appOrWeb,
    "created_at": createdAt,
    "updated_at": updatedAt.toIso8601String(),
    "deleted_at": deletedAt,
    "working_status": workingStatus.toJson(),
    "vehicle": vehicle.toJson(),
    "vehicle_registers_services": List<dynamic>.from(vehicleRegistersServices.map((x) => x.toJson())),
    "vehicle_registers_accessories": List<dynamic>.from(vehicleRegistersAccessories.map((x) => x)),
    "vehicle_registers_statuses": List<dynamic>.from(vehicleRegistersStatuses.map((x) => x.toJson())),
    "vehicle_registers_used_stocks": List<dynamic>.from(vehicleRegistersUsedStocks.map((x) => x.toJson())),
    "service_station": serviceStation.toJson(),
    "employee": employee,
    "created_byy": createdByy.toJson(),
  };
}

class CreatedByy {
  CreatedByy({
    this.id,
    this.name,
  });

  int id;
  String name;

  factory CreatedByy.fromJson(Map<String, dynamic> json) => CreatedByy(
    id: json["id"],
    name: json["name"],
  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "name": name,
  };
}

class VehicleRegistersService {
  VehicleRegistersService({
    this.id,
    this.vehicleRegistersId,
    this.serviceTypeId,
    this.serviceType,
    this.vehicleTypesSerivesPrices,
  });

  int id;
  int vehicleRegistersId;
  int serviceTypeId;
  CreatedByy serviceType;
  VehicleTypesSerivesPrices vehicleTypesSerivesPrices;

  factory VehicleRegistersService.fromJson(Map<String, dynamic> json) => VehicleRegistersService(
    id: json["id"],
    vehicleRegistersId: json["vehicle_registers_id"],
    serviceTypeId: json["service_type_id"],
    serviceType: CreatedByy.fromJson(json["service_type"]),
    vehicleTypesSerivesPrices: VehicleTypesSerivesPrices.fromJson(json["vehicle_types_serives_prices"]),
  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "vehicle_registers_id": vehicleRegistersId,
    "service_type_id": serviceTypeId,
    "service_type": serviceType.toJson(),
    "vehicle_types_serives_prices": vehicleTypesSerivesPrices.toJson(),
  };
}

class VehicleTypesSerivesPrices {
  VehicleTypesSerivesPrices({
    this.serviceTypeId,
    this.price,
  });

  int serviceTypeId;
  String price;

  factory VehicleTypesSerivesPrices.fromJson(Map<String, dynamic> json) => VehicleTypesSerivesPrices(
    serviceTypeId: json["service_type_id"],
    price: json["price"],
  );

  Map<String, dynamic> toJson() => {
    "service_type_id": serviceTypeId,
    "price": price,
  };
}

class VehicleRegistersStatus {
  VehicleRegistersStatus({
    this.id,
    this.vehicleRegistersId,
    this.workingStatusId,
    this.createdAt,
    this.workingStatus,
  });

  int id;
  int vehicleRegistersId;
  int workingStatusId;
  String createdAt;
  CreatedByy workingStatus;

  factory VehicleRegistersStatus.fromJson(Map<String, dynamic> json) => VehicleRegistersStatus(
    id: json["id"],
    vehicleRegistersId: json["vehicle_registers_id"],
    workingStatusId: json["working_status_id"],
    createdAt: json["created_at"],
    workingStatus: CreatedByy.fromJson(json["working_status"]),
  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "vehicle_registers_id": vehicleRegistersId,
    "working_status_id": workingStatusId,
    "created_at": createdAt,
    "working_status": workingStatus.toJson(),
  };
}

class VehicleRegistersUsedStock {
  VehicleRegistersUsedStock({
    this.id,
    this.vehicleRegistersId,
    this.stocksStationId,
    this.stationId,
    this.branchId,
    this.stockId,
    this.unit,
    this.kg,
    this.gm,
    this.ltr,
    this.ml,
    this.counter,
    this.createdAt,
    this.updatedAt,
    this.deletedAt,
    this.stocksStation,
    this.stock,
  });

  int id;
  int vehicleRegistersId;
  int stocksStationId;
  int stationId;
  int branchId;
  int stockId;
  int unit;
  int kg;
  int gm;
  int ltr;
  int ml;
  int counter;
  DateTime createdAt;
  DateTime updatedAt;
  dynamic deletedAt;
  VehicleRegistersUsedStock stocksStation;
  Stock stock;

  factory VehicleRegistersUsedStock.fromJson(Map<String, dynamic> json) => VehicleRegistersUsedStock(
    id: json["id"],
    vehicleRegistersId: json["vehicle_registers_id"] == null ? null : json["vehicle_registers_id"],
    stocksStationId: json["stocks_station_id"] == null ? null : json["stocks_station_id"],
    stationId: json["station_id"],
    branchId: json["branch_id"],
    stockId: json["stock_id"],
    unit: json["unit"] == null ? null : json["unit"],
    kg: json["kg"],
    gm: json["gm"],
    ltr: json["ltr"],
    ml: json["ml"],
    counter: json["counter"],
    createdAt: DateTime.parse(json["created_at"]),
    updatedAt: json["updated_at"] == null ? null : DateTime.parse(json["updated_at"]),
    deletedAt: json["deleted_at"],
    stocksStation: json["stocks_station"] == null ? null : VehicleRegistersUsedStock.fromJson(json["stocks_station"]),
    stock: json["stock"] == null ? null : Stock.fromJson(json["stock"]),
  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "vehicle_registers_id": vehicleRegistersId == null ? null : vehicleRegistersId,
    "stocks_station_id": stocksStationId == null ? null : stocksStationId,
    "station_id": stationId,
    "branch_id": branchId,
    "stock_id": stockId,
    "unit": unit == null ? null : unit,
    "kg": kg,
    "gm": gm,
    "ltr": ltr,
    "ml": ml,
    "counter": counter,
    "created_at": createdAt.toIso8601String(),
    "updated_at": updatedAt == null ? null : updatedAt.toIso8601String(),
    "deleted_at": deletedAt,
    "stocks_station": stocksStation == null ? null : stocksStation.toJson(),
    "stock": stock == null ? null : stock.toJson(),
  };
}

class Stock {
  Stock({
    this.id,
    this.stationId,
    this.name,
    this.unit,
    this.stockDate,
    this.createdAt,
    this.updatedAt,
    this.deletedAt,
  });

  int id;
  int stationId;
  String name;
  int unit;
  DateTime stockDate;
  DateTime createdAt;
  DateTime updatedAt;
  dynamic deletedAt;

  factory Stock.fromJson(Map<String, dynamic> json) => Stock(
    id: json["id"],
    stationId: json["station_id"],
    name: json["name"],
    unit: json["unit"],
    stockDate: DateTime.parse(json["stock_date"]),
    createdAt: DateTime.parse(json["created_at"]),
    updatedAt: DateTime.parse(json["updated_at"]),
    deletedAt: json["deleted_at"],
  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "station_id": stationId,
    "name": name,
    "unit": unit,
    "stock_date": "${stockDate.year.toString().padLeft(4, '0')}-${stockDate.month.toString().padLeft(2, '0')}-${stockDate.day.toString().padLeft(2, '0')}",
    "created_at": createdAt.toIso8601String(),
    "updated_at": updatedAt.toIso8601String(),
    "deleted_at": deletedAt,
  };
}

CodePudding user response:

use This Type Model 


class Data {
  int? id;
  int? stationId;
  int? branchId;
  Null? managerId;
  Null? employeeId;
  int? createdBy;
  int? vehicleId;
  String? customerName;
  String? mobile;
  String? location;
  String? registerNumber;
  int? workingStatusId;
  String? workingStatusCreatedAt;
  Null? remarks;
  String? amount;
  String? extraAmount;
  String? discount;
  String? totalAmount;
  String? suggestion;
  String? inspectionComment;
  Null? feedback;
  int? appOrWeb;
  String? createdAt;
  String? updatedAt;
  Null? deletedAt;
  WorkingStatus? workingStatus;
  WorkingStatus? vehicle;
  List<VehicleRegistersServices>? vehicleRegistersServices;
  List<Null>? vehicleRegistersAccessories;
  List<VehicleRegistersStatuses>? vehicleRegistersStatuses;
  List<VehicleRegistersUsedStocks>? vehicleRegistersUsedStocks;
  WorkingStatus? serviceStation;
  Null? employee;
  WorkingStatus? createdByy;

  Data(
      {required  this.id,
     required    this.stationId,
     required    this.branchId,
     required    this.managerId,
     required    this.employeeId,
     required    this.createdBy,
     required    this.vehicleId,
     required    this.customerName,
     required    this.mobile,
     required    this.location,
     required    this.registerNumber,
     required    this.workingStatusId,
     required    this.workingStatusCreatedAt,
     required    this.remarks,
     required    this.amount,
     required    this.extraAmount,
     required    this.discount,
     required    this.totalAmount,
     required    this.suggestion,
     required    this.inspectionComment,
     required    this.feedback,
     required    this.appOrWeb,
     required    this.createdAt,
     required    this.updatedAt,
     required    this.deletedAt,
     required    this.workingStatus,
      required    this.vehicle,
      required    this.vehicleRegistersServices,
      required    this.vehicleRegistersAccessories,
      required    this.vehicleRegistersStatuses,
      required    this.vehicleRegistersUsedStocks,
      required    this.serviceStation,
      required    this.employee,
      required    this.createdByy});

  Data.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    stationId = json['station_id'];
    branchId = json['branch_id'];
    managerId = json['manager_id'];
    employeeId = json['employee_id'];
    createdBy = json['created_by'];
    vehicleId = json['vehicle_id'];
    customerName = json['customer_name'];
    mobile = json['mobile'];
    location = json['location'];
    registerNumber = json['register_number'];
    workingStatusId = json['working_status_id'];
    workingStatusCreatedAt = json['working_status_created_at'];
    remarks = json['remarks'];
    amount = json['amount'];
    extraAmount = json['extra_amount'];
    discount = json['discount'];
    totalAmount = json['total_amount'];
    suggestion = json['suggestion'];
    inspectionComment = json['inspection_comment'];
    feedback = json['feedback'];
    appOrWeb = json['app_or_web'];
    createdAt = json['created_at'];
    updatedAt = json['updated_at'];
    deletedAt = json['deleted_at'];
    workingStatus = json['working_status'] != null
        ? new WorkingStatus.fromJson(json['working_status'])
        : null;
    vehicle = json['vehicle'] != null
        ? new WorkingStatus.fromJson(json['vehicle'])
        : null;
    if (json['vehicle_registers_services'] != null) {
      vehicleRegistersServices =   <VehicleRegistersServices>[];
      json['vehicle_registers_services'].forEach((v) {
        vehicleRegistersServices?.add(VehicleRegistersServices.fromJson(v));
      });
    }
    
    if (json['vehicle_registers_statuses'] != null) {
      vehicleRegistersStatuses = <VehicleRegistersStatuses>[];
      json['vehicle_registers_statuses'].forEach((v) {
        vehicleRegistersStatuses?.add(  VehicleRegistersStatuses.fromJson(v));
      });
    }
    if (json['vehicle_registers_used_stocks'] != null) {
      vehicleRegistersUsedStocks = <VehicleRegistersUsedStocks>[];
      json['vehicle_registers_used_stocks'].forEach((v) {
        vehicleRegistersUsedStocks
            ?.add(new VehicleRegistersUsedStocks.fromJson(v));
      });
    }
    serviceStation = json['service_station'] != null
        ? new WorkingStatus.fromJson(json['service_station'])
        : null;
    employee = json['employee'];
    createdByy = json['created_byy'] != null
        ? new WorkingStatus.fromJson(json['created_byy'])
        : null;
  }
 

  
}

class WorkingStatus {
  int? id;
  String? name;

  WorkingStatus({required this.id, required this.name});

  WorkingStatus.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
  }

  
}

class VehicleRegistersServices {
  int? id;
  int? vehicleRegistersId;
  int? serviceTypeId;
  WorkingStatus? serviceType;
  VehicleTypesSerivesPrices? vehicleTypesSerivesPrices;

  VehicleRegistersServices(
      {this.id,
        this.vehicleRegistersId,
        this.serviceTypeId,
        this.serviceType,
        this.vehicleTypesSerivesPrices});

  VehicleRegistersServices.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    vehicleRegistersId = json['vehicle_registers_id'];
    serviceTypeId = json['service_type_id'];
    serviceType = json['service_type'] != null
        ? WorkingStatus.fromJson(json['service_type'])
        : null;
    vehicleTypesSerivesPrices = json['vehicle_types_serives_prices'] != null
        ? VehicleTypesSerivesPrices.fromJson(
        json['vehicle_types_serives_prices'])
        : null;
  }

  
}

class VehicleTypesSerivesPrices {
  int? serviceTypeId;
  String? price;

  VehicleTypesSerivesPrices({required this.serviceTypeId,required this.price});

  VehicleTypesSerivesPrices.fromJson(Map<String, dynamic> json) {
    serviceTypeId = json['service_type_id'];
    price = json['price'];
  }

  
}

class VehicleRegistersStatuses {
  int? id;
  int? vehicleRegistersId;
  int? workingStatusId;
  String? createdAt;
  WorkingStatus ?workingStatus;

  VehicleRegistersStatuses(
      {required this.id,
      required  this.vehicleRegistersId,
      required  this.workingStatusId,
      required  this.createdAt,
      required  this.workingStatus});

  VehicleRegistersStatuses.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    vehicleRegistersId = json['vehicle_registers_id'];
    workingStatusId = json['working_status_id'];
    createdAt = json['created_at'];
    workingStatus = json['working_status'] != null
        ? new WorkingStatus.fromJson(json['working_status'])
        : null;
  }

  
}

class VehicleRegistersUsedStocks {
  int?  id;
  int?  vehicleRegistersId;
  int?  stocksStationId;
  int?  stationId;
  int?  branchId;
  int?  stockId;
  int?  unit;
  int?  kg;
  int?  gm;
  int?  ltr;
  int?  ml;
  int?  counter;
  String? createdAt;
  Null? updatedAt;
  Null? deletedAt;
  StocksStation? stocksStation;

  VehicleRegistersUsedStocks(
      {required this.id,
     required this.vehicleRegistersId,
     required this.stocksStationId,
     required this.stationId,
     required this.branchId,
     required this.stockId,
     required this.unit,
     required this.kg,
     required this.gm,
     required this.ltr,
     required this.ml,
     required this.counter,
     required this.createdAt,
     required this.updatedAt,
     required this.deletedAt,
     required this.stocksStation});

  VehicleRegistersUsedStocks.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    vehicleRegistersId = json['vehicle_registers_id'];
    stocksStationId = json['stocks_station_id'];
    stationId = json['station_id'];
    branchId = json['branch_id'];
    stockId = json['stock_id'];
    unit = json['unit'];
    kg = json['kg'];
    gm = json['gm'];
    ltr = json['ltr'];
    ml = json['ml'];
    counter = json['counter'];
    createdAt = json['created_at'];
    updatedAt = json['updated_at'];
    deletedAt = json['deleted_at'];
    stocksStation = json['stocks_station'] != null
        ? new StocksStation.fromJson(json['stocks_station'])
        : null;
  }

  
}

class StocksStation {
  int? id;
  int? stockId;
  int? stationId;
  int? branchId;
  int? kg;
  int? gm;
  int? ltr;
  int? ml;
  int? counter;
  String? createdAt;
  String? updatedAt;
  void deletedAt;
  Stock? stock;

  StocksStation(
      {required this.id,
      required  this.stockId,
      required  this.stationId,
      required  this.branchId,
      required  this.kg,
      required  this.gm,
      required  this.ltr,
      required  this.ml,
      required  this.counter,
      required  this.createdAt,
      required  this.updatedAt,
      required  this.deletedAt,
      required  this.stock});

  StocksStation.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    stockId = json['stock_id'];
    stationId = json['station_id'];
    branchId = json['branch_id'];
    kg = json['kg'];
    gm = json['gm'];
    ltr = json['ltr'];
    ml = json['ml'];
    counter = json['counter'];
    createdAt = json['created_at'];
    updatedAt = json['updated_at'];
    deletedAt = json['deleted_at'];
    stock = (json['stock'] != null ? new Stock.fromJson(json['stock']) : null)!;
  }

  
}

class Stock {
  int? id;
  int? stationId;
  String? name;
  int? unit;
  String? stockDate;
  String? createdAt;
  String? updatedAt;
  void deletedAt;

  Stock(
      {required this.id,
       required this.stationId,
       required this.name,
       required this.unit,
       required this.stockDate,
       required this.createdAt,
       required this.updatedAt,
       required this.deletedAt});

  Stock.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    stationId = json['station_id'];
    name = json['name'];
    unit = json['unit'];
    stockDate = json['stock_date'];
    createdAt = json['created_at'];
    updatedAt = json['updated_at'];
    deletedAt = json['deleted_at'];
  }

  
}

CodePudding user response:

If you set "Content-Type": "application/json" your response data is a json object and you have a parameter type String in that method: DeleteModel deleteModelFromJson(String str). Change to same type.

  • Related