Skip to content

Instantly share code, notes, and snippets.

@wess
Last active Sep 3, 2021
Embed
What would you like to do?
import 'dart:convert';
class Meta {
Map<String, dynamic> _backing;
dynamic get(String key) => _backing[key];
void insert(Map<String, dynamic> data) => _backing = {..._backing, ...data};
Meta set(String key, dynamic value) {
_backing[key] = value;
return this;
}
void clear() => _backing = {};
String toJson() => json.encode(_backing);
Meta(): _backing = {};
factory Meta.fromJson(String str) {
final meta = Meta();
meta.insert(
json.decode(str)
);
return meta;
}
operator [](String key) => _backing[key];
operator []=(String key, dynamic value) => _backing[key] = value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment