import 'dart:convert'; import 'package:flutter/foundation.dart'; import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart'; /* { "category": "kg", "time": "2024-09-22T10:31:54Z", "function": { "code": "switch_1", "value": true }, "days": [ "Sun" ] } */ class SendSchedule { final String category; final String time; final Status function; final List days; SendSchedule({ required this.category, required this.time, required this.function, required this.days, }); SendSchedule copyWith({ String? category, String? time, Status? function, List? days, }) { return SendSchedule( category: category ?? this.category, time: time ?? this.time, function: function ?? this.function, days: days ?? this.days, ); } Map toMap() { return { 'category': category, 'time': time, 'function': function.toMap(), 'days': days, }; } factory SendSchedule.fromMap(Map map) { return SendSchedule( category: map['category'] ?? '', time: map['time'] ?? '', function: Status.fromMap(map['function']), days: List.from(map['days']), ); } String toJson() => json.encode(toMap()); factory SendSchedule.fromJson(String source) => SendSchedule.fromMap(json.decode(source)); @override String toString() { return 'SendSchedule(category: $category, time: $time, function: $function, days: $days)'; } @override bool operator ==(Object other) { if (identical(this, other)) return true; return other is SendSchedule && other.category == category && other.time == time && other.function == function && listEquals(other.days, days); } @override int get hashCode { return category.hashCode ^ time.hashCode ^ function.hashCode ^ days.hashCode; } }