You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			56 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			56 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Dart
		
	
import 'package:test_sa/models/base.dart';
 | 
						|
import 'package:test_sa/models/new_models/floor.dart';
 | 
						|
 | 
						|
class Building extends Base {
 | 
						|
  Building({
 | 
						|
    this.id,
 | 
						|
    this.value,
 | 
						|
    this.floors,
 | 
						|
    String name,
 | 
						|
  }) : super(identifier: id.toString(), name: name);
 | 
						|
 | 
						|
  Building.fromJson(dynamic json) {
 | 
						|
    id = json['id'];
 | 
						|
    identifier = id.toString();
 | 
						|
    name = json['name'];
 | 
						|
    value = json['value'];
 | 
						|
    if (json['floors'] != null) {
 | 
						|
      floors = [];
 | 
						|
      json['floors'].forEach((v) {
 | 
						|
        floors.add(Floor.fromJson(v));
 | 
						|
      });
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
  num id;
 | 
						|
  num value;
 | 
						|
  List<Floor> floors;
 | 
						|
 | 
						|
  Building copyWith({
 | 
						|
    num id,
 | 
						|
    String name,
 | 
						|
    num value,
 | 
						|
    List<Floor> floors,
 | 
						|
  }) =>
 | 
						|
      Building(
 | 
						|
        id: id ?? this.id,
 | 
						|
        name: name ?? this.name,
 | 
						|
        value: value ?? this.value,
 | 
						|
        floors: floors ?? this.floors,
 | 
						|
      );
 | 
						|
 | 
						|
  Map<String, dynamic> toJson({bool addFloor = true}) {
 | 
						|
    final map = <String, dynamic>{};
 | 
						|
    map['id'] = id;
 | 
						|
    map['name'] = name;
 | 
						|
    map['value'] = value;
 | 
						|
    if (addFloor) {
 | 
						|
      if (floors != null) {
 | 
						|
        map['floors'] = floors.map((v) => v.toJson()).toList();
 | 
						|
      }
 | 
						|
    }
 | 
						|
 | 
						|
    return map;
 | 
						|
  }
 | 
						|
}
 |