Skip to content

Commit 07d2cc3

Browse files
committed
Section Four, Video Six: Note Model class ( note.dart )
1 parent 4e196f5 commit 07d2cc3

File tree

5 files changed

+147
-2
lines changed

5 files changed

+147
-2
lines changed

.idea/libraries/Dart_Packages.xml

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/libraries/Flutter_Plugins.xml

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/models/note.dart

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
2+
class Note {
3+
4+
int _id;
5+
String _title;
6+
String _description;
7+
String _date;
8+
int _priority;
9+
10+
Note(this._title, this._date, this._priority, [this._description]);
11+
12+
Note.withId(this._id, this._title, this._date, this._priority, [this._description]);
13+
14+
int get id => _id;
15+
16+
String get title => _title;
17+
18+
String get description => _description;
19+
20+
int get priority => _priority;
21+
22+
String get date => _date;
23+
24+
set title(String newTitle) {
25+
if (newTitle.length <= 255) {
26+
this._title = newTitle;
27+
}
28+
}
29+
30+
set description(String newDescription) {
31+
if (newDescription.length <= 255) {
32+
this._description = newDescription;
33+
}
34+
}
35+
36+
set priority(int newPriority) {
37+
if (newPriority >= 1 && newPriority <= 2) {
38+
this._priority = newPriority;
39+
}
40+
}
41+
42+
set date(String newDate) {
43+
this._date = newDate;
44+
}
45+
46+
// Convert a Note object into a Map object
47+
Map<String, dynamic> toMap() {
48+
49+
var map = Map<String, dynamic>();
50+
if (id != null) {
51+
map['id'] = _id;
52+
}
53+
map['title'] = _title;
54+
map['description'] = _description;
55+
map['priority'] = _priority;
56+
map['date'] = _date;
57+
58+
return map;
59+
}
60+
61+
// Extract a Note object from a Map object
62+
Note.fromMapObject(Map<String, dynamic> map) {
63+
this._id = map['id'];
64+
this._title = map['title'];
65+
this._description = map['description'];
66+
this._priority = map['priority'];
67+
this._date = map['date'];
68+
}
69+
}
70+
71+
72+
73+
74+
75+
76+
77+
78+

pubspec.lock

+30-1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ packages:
123123
url: "https://pub.dartlang.org"
124124
source: hosted
125125
version: "3.1.3"
126+
intl:
127+
dependency: "direct main"
128+
description:
129+
name: intl
130+
url: "https://pub.dartlang.org"
131+
source: hosted
132+
version: "0.15.7"
126133
io:
127134
dependency: transitive
128135
description:
@@ -214,6 +221,13 @@ packages:
214221
url: "https://pub.dartlang.org"
215222
source: hosted
216223
version: "1.6.2"
224+
path_provider:
225+
dependency: "direct main"
226+
description:
227+
name: path_provider
228+
url: "https://pub.dartlang.org"
229+
source: hosted
230+
version: "0.4.1"
217231
plugin:
218232
dependency: transitive
219233
description:
@@ -296,6 +310,13 @@ packages:
296310
url: "https://pub.dartlang.org"
297311
source: hosted
298312
version: "1.4.1"
313+
sqflite:
314+
dependency: "direct main"
315+
description:
316+
name: sqflite
317+
url: "https://pub.dartlang.org"
318+
source: hosted
319+
version: "0.12.2+1"
299320
stack_trace:
300321
dependency: transitive
301322
description:
@@ -317,6 +338,13 @@ packages:
317338
url: "https://pub.dartlang.org"
318339
source: hosted
319340
version: "1.0.4"
341+
synchronized:
342+
dependency: transitive
343+
description:
344+
name: synchronized
345+
url: "https://pub.dartlang.org"
346+
source: hosted
347+
version: "1.5.3"
320348
term_glyph:
321349
dependency: transitive
322350
description:
@@ -381,4 +409,5 @@ packages:
381409
source: hosted
382410
version: "2.1.15"
383411
sdks:
384-
dart: ">=2.0.0-dev.68.0 <3.0.0"
412+
dart: ">=2.0.0 <3.0.0"
413+
flutter: ">=0.1.4 <2.0.0"

pubspec.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ description: My journey to learn flutter.
44
dependencies:
55
flutter:
66
sdk: flutter
7+
sqflite: any
8+
path_provider: any
9+
intl: ^0.15.7
710

811
# The following adds the Cupertino Icons font to your application.
912
# Use with the CupertinoIcons class for iOS style icons.

0 commit comments

Comments
 (0)