class Note { final String id; final String title; final String content; final DateTime createdAt; final DateTime updatedAt; const Note({ required this.id, required this.title, required this.content, required this.createdAt, required this.updatedAt, }); Note copyWith({ String? title, String? content, DateTime? updatedAt, }) { return Note( id: id, title: title ?? this.title, content: content ?? this.content, createdAt: createdAt, updatedAt: updatedAt ?? this.updatedAt, ); } Map toJson() => { 'id': id, 'title': title, 'content': content, 'created_at': createdAt.toIso8601String(), 'updated_at': updatedAt.toIso8601String(), }; factory Note.fromJson(Map json) => Note( id: json['id'] as String, title: json['title'] as String, content: json['content'] as String, createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), ); // SQLite row → Note factory Note.fromMap(Map map) => Note( id: map['id'] as String, title: map['title'] as String, content: map['content'] as String, createdAt: DateTime.parse(map['created_at'] as String), updatedAt: DateTime.parse(map['updated_at'] as String), ); // Note → SQLite row Map toMap() => { 'id': id, 'title': title, 'content': content, 'created_at': createdAt.toIso8601String(), 'updated_at': updatedAt.toIso8601String(), }; @override String toString() => 'Note(id: $id, title: $title)'; }