toMap method
Implementation
Map<String, dynamic> toMap({List<String> excludes = const []}) {
InstanceMirror im = reflect(this);
ClassMirror cm = im.type;
Map<String, dynamic> map = {};
cm.declarations.values.whereType<VariableMirror>().forEach((vm) {
final key = MirrorSystem.getName(vm.simpleName);
final value = im.getField(vm.simpleName).reflectee;
if (!(excludes.indexWhere((field) => field == key) > -1)) {
map[key] = value;
}
});
return map;
}