mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 09:27:54 +00:00
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:
@@ -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?,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user