toMap method
Implementation
Map<String, dynamic> toMap() {
Map<String, dynamic> map = {
"type": type.toNativeValue(),
"selector": selector
};
map.keys
.where((key) =>
map[key] == null ||
(map[key] is List && (map[key] as List).length == 0)) // filter keys
.toList() // create a copy to avoid concurrent modifications
.forEach(map.remove);
return map;
}