Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'dart:convert';
- import 'package:equatable/equatable.dart';
- class RepairDto extends Equatable {
- final int? id_repair;
- final String? customer;
- final DateTime? date_accept;
- final DateTime? date_delive;
- final String? user;
- final String? technician;
- final bool? warranty;
- final String? name_image;
- final String? objects;
- final String? works_to_do;
- final double? p_cost;
- final double? p_part1;
- final double? p_part2;
- final double? p_part3;
- final String? note;
- final double? p_public;
- RepairDto({
- this.id_repair,
- this.customer,
- this.date_accept,
- this.date_delive,
- this.user,
- this.technician,
- this.warranty,
- this.name_image,
- this.objects,
- this.works_to_do,
- this.p_cost,
- this.p_part1,
- this.p_part2,
- this.p_part3,
- this.note,
- this.p_public,
- });
- RepairDto copyWith({
- int? id_repair,
- String? customer,
- DateTime? date_accept,
- DateTime? date_delive,
- String? user,
- String? technician,
- bool? warranty,
- String? path_image,
- String? objects,
- String? works_to_do,
- double? p_cost,
- double? p_part1,
- double? p_part2,
- double? p_part3,
- String? note,
- double? p_public,
- }) {
- return RepairDto(
- id_repair: id_repair ?? this.id_repair,
- customer: customer ?? this.customer,
- date_accept: date_accept ?? this.date_accept,
- date_delive: date_delive ?? this.date_delive,
- user: user ?? this.user,
- technician: technician ?? this.technician,
- warranty: warranty ?? this.warranty,
- name_image: path_image ?? this.name_image,
- objects: objects ?? this.objects,
- works_to_do: works_to_do ?? this.works_to_do,
- p_cost: p_cost ?? this.p_cost,
- p_part1: p_part1 ?? this.p_part1,
- p_part2: p_part2 ?? this.p_part2,
- p_part3: p_part3 ?? this.p_part3,
- note: note ?? this.note,
- p_public: p_public ?? this.p_public,
- );
- }
- Map<String, dynamic> toMap() {
- return {
- 'id_repair': id_repair,
- 'customer': customer,
- 'date_accept': date_accept?.millisecondsSinceEpoch,
- 'date_delive': date_delive?.millisecondsSinceEpoch,
- 'user': user,
- 'technician': technician,
- 'warranty': warranty,
- 'path_image': name_image,
- 'objects': objects,
- 'works_to_do': works_to_do,
- 'p_cost': p_cost,
- 'p_part1': p_part1,
- 'p_part2': p_part2,
- 'p_part3': p_part3,
- 'note': note,
- 'p_public': p_public,
- };
- }
- factory RepairDto.fromMap(Map<String, dynamic> map) {
- return RepairDto(
- id_repair: map['id_repair']?.toInt(),
- customer: map['customer'],
- date_accept: map['date_accept'] != null
- ? DateTime.fromMillisecondsSinceEpoch(map['date_accept'])
- : null,
- date_delive: map['date_delive'] != null
- ? DateTime.fromMillisecondsSinceEpoch(map['date_delive'])
- : null,
- user: map['user'],
- technician: map['technician'],
- warranty: map['warranty'],
- name_image: map['name_image'],
- objects: map['objects'],
- works_to_do: map['works_to_do'],
- p_cost: map['p_cost']?.toDouble(),
- p_part1: map['p_part1']?.toDouble(),
- p_part2: map['p_part2']?.toDouble(),
- p_part3: map['p_part3']?.toDouble(),
- note: map['note'],
- p_public: map['p_public']?.toDouble(),
- );
- }
- String toJson() => json.encode(toMap());
- factory RepairDto.fromJson(String source) =>
- RepairDto.fromMap(json.decode(source));
- @override
- String toString() {
- return 'RepairDto(id_repair: $id_repair, customer: $customer, date_accept: $date_accept, date_delive: $date_delive, user: $user, technician: $technician, warranty: $warranty, name_image: $name_image, objects: $objects, works_to_do: $works_to_do, p_cost: $p_cost, p_part1: $p_part1, p_part2: $p_part2, p_part3: $p_part3, note: $note, p_public: $p_public)';
- }
- @override
- List<Object?> get props {
- return [
- id_repair,
- customer,
- date_accept,
- date_delive,
- user,
- technician,
- warranty,
- name_image,
- objects,
- works_to_do,
- p_cost,
- p_part1,
- p_part2,
- p_part3,
- note,
- p_public,
- ];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement