typedef NoteAdder(Note note); typedef NoteRemover(Note note); typedef NoteUpdator(Note note); class Note implements Comparable { String id; DateTime createdAt; String body; Note({this.createdAt, this.body, this.id}); factory Note.fromJson(Map json) { String id; if (json.containsKey("id")) { var val = json["id"]; if (val.runtimeType == String) { id = val; } else { id = val.toString(); } } return new Note( id: id, createdAt: DateTime.parse(json['createdAt']), body: json['body'], ); } Map toJson() { return { "createdAt": createdAt.toIso8601String(), "body": body, "id": id, }; } @override int get hashCode => id.hashCode ^ createdAt.hashCode ^ body.hashCode; @override bool operator ==(Object other) => identical(this, other) || other is Note && runtimeType == other.runtimeType && id == other.id && body == other.body && createdAt == other.createdAt; @override String toString() { return 'Note{id: $id, body: $body, createdAt: $createdAt}'; } @override int compareTo(other) => createdAt.compareTo(other.createdAt); } class AppState { bool isLoading; List notes; AppState({ this.isLoading = false, this.notes = const [], }); factory AppState.loading() => AppState(isLoading: true); }