Look at the following code snippet.
import "dart:mirrors";
class meta {
final String data;
const meta(this.data);
}
@meta("Tag")
doSomething() => print("You have to do something");
void main() {
doSomething();
}
How can I retrieve functions, that is market with metadata tags? In my example, I want to find out, which method is marked with meta tags.
you could do something like this:
This should give you:
You could also analyze your files from another project and use dart:mirrors on that file instead of inspecting the current library. Maybe
libraries.values.last
will not always return the current library - so you might need to change it. In my case it worked.see also How can i test the existence of a function in Dart?