import 'package:hive/hive.dart'; // flutter packages pub run build_runner build part 'reminder.g.dart'; @HiveType(typeId: 1) class Reminder extends HiveObject { @HiveField(0) late int id; @HiveField(1) late String title; @HiveField(2) late String content; @HiveField(3) late DateTime scheduledTime; @HiveField(4) late DateTime createTime; @HiveField(5) late DateTime updateTime; Reminder({ int? id, required this.title, required this.content, required this.scheduledTime, DateTime? createTime, DateTime? updateTime, }) { // 简单时间戳ID this.id = id ?? DateTime.now().millisecondsSinceEpoch ~/ 1000; this.createTime = createTime ?? DateTime.now(); this.updateTime = updateTime ?? DateTime.now(); } Reminder copyWith({String? title, String? content, DateTime? scheduledTime}) { return Reminder( id: id, title: title ?? this.title, content: content ?? this.content, scheduledTime: scheduledTime ?? this.scheduledTime, createTime: createTime, updateTime: DateTime.now(), ); } static Reminder getEmpty() { return Reminder( id: DateTime.now().millisecondsSinceEpoch ~/ 1000, title: '日常提醒', content: '', scheduledTime: DateTime.now().add(Duration(minutes: 5)), ); } }