import 'package:test_sa/models/base.dart'; import 'package:test_sa/models/new_models/assigned_employee.dart'; class AssistantEmployees extends Base { AssistantEmployees({ this.id, this.user, }) : super(name: user?.name, identifier: user?.id); AssistantEmployees.fromJson(dynamic json) { id = json['id']; user = json['user'] != null ? AssignedEmployee.fromJson(json['user']) : null; name = user?.name; identifier = user?.id; } num? id; // Now nullable AssignedEmployee? user; // Now nullable AssistantEmployees copyWith({ num? id, // Parameter is now nullable AssignedEmployee? user, // Parameter is now nullable }) => AssistantEmployees( id: id ?? this.id, user: user ?? this.user, ); Map toJson() { final map = {}; map['id'] = id; if (user != null) { map['user'] = user?.toJson(); // Use '?.' to handle potential null } return map; } }