mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 01:35:23 +00:00
45 lines
1.3 KiB
Dart
45 lines
1.3 KiB
Dart
import 'dart:convert';
|
|
import 'dart:typed_data';
|
|
|
|
class ScenesModel {
|
|
final String id;
|
|
final String? sceneTuyaId;
|
|
final String name;
|
|
final String status;
|
|
final String type;
|
|
final String? icon;
|
|
|
|
ScenesModel(
|
|
{required this.id,
|
|
this.sceneTuyaId,
|
|
required this.name,
|
|
required this.status,
|
|
required this.type,
|
|
this.icon});
|
|
|
|
factory ScenesModel.fromRawJson(String str) =>
|
|
ScenesModel.fromJson(json.decode(str));
|
|
|
|
String toRawJson() => json.encode(toJson());
|
|
Uint8List get iconInBytes => base64Decode(icon ?? '');
|
|
|
|
factory ScenesModel.fromJson(Map<String, dynamic> json) {
|
|
return ScenesModel(
|
|
id: json["id"] ?? json["uuid"] ?? '', // Fallback to empty string if id is null
|
|
sceneTuyaId: json["sceneTuyaId"] as String?, // Nullable
|
|
name: json["name"] ?? '', // Fallback to empty string if name is null
|
|
status:
|
|
json["status"] ?? '', // Fallback to empty string if status is null
|
|
type: json["type"] ?? '', // Fallback to empty string if type is null
|
|
icon: json["icon"] as String?, // Nullable
|
|
);
|
|
}
|
|
Map<String, dynamic> toJson() => {
|
|
"id": id,
|
|
"sceneTuyaId": sceneTuyaId ?? '',
|
|
"name": name,
|
|
"status": status,
|
|
"type": type,
|
|
};
|
|
}
|