mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-27 17:29:50 +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>();
|
||||
|
||||
Note({this.created, this.body, this.fileName, this.extraProperties}) {
|
||||
assert(this.created != null);
|
||||
assert(this.body != null);
|
||||
assert(this.fileName != null);
|
||||
|
||||
if (extraProperties == null) {
|
||||
extraProperties = new Map<String, dynamic>();
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class MarkdownYAMLSerializer implements NoteSerializer {
|
||||
var parts = str.split("---\n");
|
||||
|
||||
var yamlMap = loadYaml(parts[1]);
|
||||
Map<String, dynamic> map = new Map<String, dynamic>();
|
||||
var map = new Map<String, dynamic>();
|
||||
yamlMap.forEach((key, value) {
|
||||
map[key] = value;
|
||||
});
|
||||
@ -37,7 +37,9 @@ class MarkdownYAMLSerializer implements NoteSerializer {
|
||||
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
|
||||
|
Reference in New Issue
Block a user