31 lines
810 B
Dart
31 lines
810 B
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
part 'hydration.freezed.dart';
|
|
part 'hydration.g.dart';
|
|
|
|
@freezed
|
|
class Hydration with _$Hydration {
|
|
const factory Hydration({
|
|
required String widgetType,
|
|
required String name,
|
|
required int button1Amount,
|
|
required int button2Amount,
|
|
required int goal,
|
|
required int current,
|
|
required bool isExpanded,
|
|
required bool isVisible,
|
|
required String createdOn,
|
|
required String completedOn,
|
|
@Default(-1) int id,
|
|
}) = _Hydration;
|
|
|
|
factory Hydration.fromJson(Map<String, Object?> json) =>
|
|
_$HydrationFromJson(json);
|
|
}
|
|
|
|
extension JsonWithoutId on Hydration {
|
|
Map<String, dynamic> toJsonWithoutId() {
|
|
final map = toJson()..remove('id');
|
|
return map;
|
|
}
|
|
}
|