class Note { final int id; final String title; final String body; final DateTime createdAt; final DateTime updatedAt; const Note({ required this.id, required this.title, required this.body, required this.createdAt, required this.updatedAt, }); factory Note.fromJson(Map json) => Note( id: json['id'] as int, title: json['title'] as String? ?? '', body: json['body'] as String? ?? '', createdAt: DateTime.parse(json['created_at'] as String), updatedAt: DateTime.parse(json['updated_at'] as String), ); Map toJson() => { 'title': title, 'body': body, }; Note copyWith({String? title, String? body}) => Note( id: id, title: title ?? this.title, body: body ?? this.body, createdAt: createdAt, updatedAt: updatedAt, ); }