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.
49 lines
1.6 KiB
Dart
49 lines
1.6 KiB
Dart
import 'package:test_sa/models/base.dart';
|
|
|
|
class Rooms extends Base {
|
|
int? id; // Now nullable
|
|
@override
|
|
String? name; // Now nullable
|
|
int?value; // Now nullable
|
|
|
|
Rooms({this.id, this.name, this.value}) : super(identifier: id?.toString() ?? '', name: name); // Handle potential null id
|
|
|
|
Rooms.fromJson(Map<String, dynamic>? json) {
|
|
// Handle potential null json input
|
|
id = json?['id']; // Use null-aware operator
|
|
name = json?['name'];
|
|
value = json?['value'];
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['id'] = id;
|
|
data['name'] = name;
|
|
data['value'] = value;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
// class Rooms extends Base {
|
|
// int? id; // Now nullable
|
|
// int? departmentId; // Now nullable
|
|
// int? clientRoomId; // Now nullable
|
|
// String? roomName; // Now nullable
|
|
//
|
|
// Rooms({this.id, this.departmentId, this.clientRoomId, this.roomName}) : super(identifier: id?.toString() ?? '', name: roomName); // Handle potential null id
|
|
//
|
|
// Rooms.fromJson(Map<String, dynamic>? json) { // Handle potential null json input
|
|
// id = json?['id']; // Use null-aware operator
|
|
// departmentId = json?['departmentId'];
|
|
// clientRoomId = json?['clientRoomId'];
|
|
// roomName = json?['roomName'];
|
|
// }
|
|
//
|
|
// Map<String, dynamic> toJson() {
|
|
// final Map<String, dynamic> data = new Map<String, dynamic>();// data['id'] = this.id;
|
|
// data['departmentId'] = this.departmentId;
|
|
// data['clientRoomId'] = this.clientRoomId;
|
|
// data['roomName'] = this.roomName;
|
|
// return data;
|
|
// }
|
|
// } |