50 lines
1.1 KiB
Dart
50 lines
1.1 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
part 'timer.freezed.dart';
|
|
part 'timer.g.dart';
|
|
|
|
@freezed
|
|
class TimerItem with _$TimerItem {
|
|
const factory TimerItem({
|
|
required String widgetType,
|
|
required String name,
|
|
required int current,
|
|
required int goal,
|
|
required bool isExpanded,
|
|
required bool isVisible,
|
|
required String createdOn,
|
|
required String completedOn,
|
|
required String state,
|
|
@Default(-1) int id,
|
|
}) = _TimerItem;
|
|
|
|
factory TimerItem.fromJson(Map<String, Object?> json) =>
|
|
_$TimerItemFromJson(json);
|
|
}
|
|
|
|
extension JsonWithoutId on TimerItem {
|
|
Map<String, dynamic> toJsonWithoutId() {
|
|
final map = toJson()..remove('id');
|
|
return map;
|
|
}
|
|
}
|
|
|
|
/*
|
|
@freezed
|
|
class Student with _$Student {
|
|
const factory Student({
|
|
required String name,
|
|
int? id,
|
|
}) = _Student;
|
|
|
|
factory Student.fromJson(Map<String, Object?> json) =>
|
|
_$StudentFromJson(json);
|
|
}
|
|
|
|
extension JsonWithoutId on Student {
|
|
Map<String, dynamic> toJsonWithoutId() {
|
|
final map = toJson()..remove('id');
|
|
return map;
|
|
}
|
|
}
|
|
*/
|