mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 02:07:39 +08:00
Note: Never let the created be null
Null paramters are annoying, cause we then need to check if != null all the time. I hate this about Dart. A type should always have sensible defaults.
This commit is contained in:
@ -12,6 +12,10 @@ class Note implements Comparable {
|
|||||||
Map<String, dynamic> extraProperties = new Map<String, dynamic>();
|
Map<String, dynamic> extraProperties = new Map<String, dynamic>();
|
||||||
|
|
||||||
Note({this.created, this.body, this.fileName, this.extraProperties}) {
|
Note({this.created, this.body, this.fileName, this.extraProperties}) {
|
||||||
|
assert(this.created != null);
|
||||||
|
assert(this.body != null);
|
||||||
|
assert(this.fileName != null);
|
||||||
|
|
||||||
if (extraProperties == null) {
|
if (extraProperties == null) {
|
||||||
extraProperties = new Map<String, dynamic>();
|
extraProperties = new Map<String, dynamic>();
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class MarkdownYAMLSerializer implements NoteSerializer {
|
|||||||
var parts = str.split("---\n");
|
var parts = str.split("---\n");
|
||||||
|
|
||||||
var yamlMap = loadYaml(parts[1]);
|
var yamlMap = loadYaml(parts[1]);
|
||||||
Map<String, dynamic> map = new Map<String, dynamic>();
|
var map = new Map<String, dynamic>();
|
||||||
yamlMap.forEach((key, value) {
|
yamlMap.forEach((key, value) {
|
||||||
map[key] = value;
|
map[key] = value;
|
||||||
});
|
});
|
||||||
@ -37,7 +37,9 @@ class MarkdownYAMLSerializer implements NoteSerializer {
|
|||||||
return new Note.fromJson(map);
|
return new Note.fromJson(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Note(body: str);
|
var map = new Map<String, dynamic>();
|
||||||
|
map['body'] = str;
|
||||||
|
return new Note.fromJson(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
Reference in New Issue
Block a user