-
Notifications
You must be signed in to change notification settings - Fork 1
/
notes_states.dart
71 lines (55 loc) · 1.58 KB
/
notes_states.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import 'package:equatable/equatable.dart';
import '../../data/models/note.dart';
abstract class NotesState extends Equatable {
List<Note> get notes;
NotesState copyWith(List<Note> updatedNotes);
@override
List<Object> get props => [...notes.map((e) => e)];
Map<String, dynamic>? toMap() {
return {"notes": notes.map((e) => e.toMap()).toList()};
}
}
class NotesInitial extends NotesState {
@override
List<Note> get notes => [];
@override
NotesState copyWith(List<Note> updatedNotes) => NotesInitial();
}
class NotesEmpty extends NotesState {
@override
List<Note> get notes => [];
@override
NotesState copyWith(List<Note> updatedNotes) => NotesEmpty();
}
class NotesLoading extends NotesState {
NotesLoading(this._notes);
final List<Note> _notes;
@override
List<Note> get notes => _notes;
@override
NotesState copyWith(List<Note> updatedNotes) => NotesLoading(updatedNotes);
}
class NotesError extends NotesState {
NotesError(this._notes);
final List<Note> _notes;
@override
List<Note> get notes => _notes;
@override
NotesState copyWith(List<Note> updatedNotes) => NotesError(updatedNotes);
}
class NotesLoaded extends NotesState {
NotesLoaded(this._notes);
final List<Note> _notes;
@override
NotesLoaded copyWith(List<Note> updatedNotes) => NotesLoaded(updatedNotes);
@override
List<Note> get notes => _notes;
}
class AddingNote extends NotesState {
AddingNote(this._notes);
final List<Note> _notes;
@override
AddingNote copyWith(List<Note> updatedNotes) => AddingNote(updatedNotes);
@override
List<Note> get notes => _notes;
}