mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
40 lines
1.0 KiB
Dart
40 lines
1.0 KiB
Dart
import 'dart:convert';
|
|
import 'dart:typed_data';
|
|
|
|
class IconModel {
|
|
final String uuid;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
final String iconBase64;
|
|
|
|
IconModel({
|
|
required this.uuid,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
required this.iconBase64,
|
|
});
|
|
|
|
// Method to decode the icon from Base64 and return as Uint8List
|
|
Uint8List get iconBytes => base64Decode(iconBase64);
|
|
|
|
// Factory constructor to create an instance from JSON
|
|
factory IconModel.fromJson(Map<String, dynamic> json) {
|
|
return IconModel(
|
|
uuid: json['uuid'] as String,
|
|
createdAt: DateTime.parse(json['createdAt'] as String),
|
|
updatedAt: DateTime.parse(json['updatedAt'] as String),
|
|
iconBase64: json['icon'] as String,
|
|
);
|
|
}
|
|
|
|
// Method to convert an instance back to JSON
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'uuid': uuid,
|
|
'createdAt': createdAt.toIso8601String(),
|
|
'updatedAt': updatedAt.toIso8601String(),
|
|
'icon': iconBase64,
|
|
};
|
|
}
|
|
}
|