Refactor device filtering logic and improve code readability

- Extracted the logic for filtering implemented devices into a separate method `_getOnlyImplementedDevices`
- Created a set `allowedDevices` to store the allowed device types
- Updated the filtering logic to use the `allowedDevices` set for checking device types
- Removed unnecessary conditions for filtering devices

Fix nullability issues in `Action` model

- Added null checks for `actionExecutor`, `entityId`, `name`, `type`, and `productType` properties in the `fromJson` method of the `Action` model
- Set default values for `actionExecutor` and `entityId` if they are null
- Updated the type casting for `name`, `type`, and `productType` properties to avoid potential nullability issues
This commit is contained in:
mohammad
2025-04-17 10:16:10 +03:00
parent 1cff69d496
commit 7005d8ba83
2 changed files with 26 additions and 18 deletions
@@ -90,11 +90,11 @@ class Action {
static Action? fromJson(Map<String, dynamic> json) {
if (json['name'] != null && json['type'] != null) {
return Action(
actionExecutor: json["actionExecutor"],
entityId: json["entityId"],
name: json['name'],
type: json['type'],
productType: json['productType'],
actionExecutor: json["actionExecutor"] ?? '',
entityId: json["entityId"] ?? '',
name: json['name'] as String?,
type: json['type'] as String?,
productType: json['productType'] as String?,
);
}
if (json["executorProperty"] == null) {
@@ -102,10 +102,10 @@ class Action {
}
return Action(
actionExecutor: json["actionExecutor"],
entityId: json["entityId"],
actionExecutor: json["actionExecutor"] ?? '',
entityId: json["entityId"] ?? '',
executorProperty: ExecutorProperty.fromJson(json["executorProperty"]),
productType: json['productType'],
productType: json['productType'] as String?,
);
}