getAnnotations method
Implementation
Map<String, String> getAnnotations(ClassElement element) {
Map<String, String> ret = {};
element.metadata.forEach((annotation) {
String source = annotation.toSource();
source = source.replaceFirst('@', '');
if (['Compose', 'ComposeSubtypes'].contains(source)) {
//todo better list of build in annotations
return;
}
String key = source;
if (source.indexOf('(') > -1) {
key = source.substring(0, source.indexOf('('));
}
if (!ret.containsKey(key)) {
var value = 'true';
//todo support multiple values?
if (source!=key) {
value = source.replaceAll(key, '');
value = value.replaceFirst('(', '');
value = value.replaceFirst(')', '');
}
ret[key] = value;
}
});
return ret;
}