Files
GitJournal/lib/core/md_yaml_doc.dart
Vishesh Handa 46a38cdedf Rename NoteData -> MdYamlDoc
It more clearly defines what exactly it is.

This is important as its less confusing for when we add support for
other file types.
2020-02-14 08:12:41 +01:00

40 lines
1.0 KiB
Dart

import 'dart:collection';
class MdYamlDoc {
String body = "";
LinkedHashMap<String, dynamic> props = LinkedHashMap<String, dynamic>();
MdYamlDoc([this.body, this.props]) {
body = body ?? "";
// ignore: prefer_collection_literals
props = props ?? LinkedHashMap<String, dynamic>();
}
MdYamlDoc.from(MdYamlDoc other) {
body = String.fromCharCodes(other.body.codeUnits);
props = LinkedHashMap<String, dynamic>.from(other.props);
}
@override
int get hashCode => body.hashCode ^ props.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is MdYamlDoc &&
runtimeType == other.runtimeType &&
body == other.body &&
_equalMaps(props, other.props);
static bool _equalMaps(Map a, Map b) {
if (a.length != b.length) return false;
return a.keys
.every((dynamic key) => b.containsKey(key) && a[key] == b[key]);
}
@override
String toString() {
return 'NoteData{body: $body, props: $props}';
}
}