Updated OccupancyHeatMapModel model with what the api returns, and only used the necessary fields that the api returns for this feature to work.

This commit is contained in:
Faris Armoush
2025-05-14 10:51:19 +03:00
parent 300f9ae358
commit d1bb8da484
2 changed files with 17 additions and 8 deletions

View File

@ -1,22 +1,28 @@
import 'package:equatable/equatable.dart';
class OccupancyHeatMapModel extends Equatable {
final DateTime date;
final String uuid;
final int occupancy;
final DateTime eventDate;
final int countTotalPresenceDetected;
const OccupancyHeatMapModel({
required this.date,
required this.occupancy,
required this.uuid,
required this.eventDate,
required this.countTotalPresenceDetected,
});
factory OccupancyHeatMapModel.fromJson(Map<String, dynamic> json) {
return OccupancyHeatMapModel(
date: DateTime.parse(json['date'] as String),
occupancy: json['occupancy'] as int,
uuid: json['uuid'] as String? ?? '',
eventDate: DateTime.parse(
json['event_date'] as String? ?? '${DateTime.now()}',
),
countTotalPresenceDetected: json['count_total_presence_detected'] as int? ?? 0,
);
}
@override
List<Object?> get props => [date, occupancy];
List<Object?> get props => [uuid, eventDate, countTotalPresenceDetected];
}