dart: reflect methods of a class, no luck with the reflect*() functions

150 Views Asked by At

I'm trying to list the methods of a class, but neither reflectClass() nor reflectType() return anything useful. Has anyone done this already?

This is my code:

import 'package:mylib/mylib.dart' as mylib;
import 'dart:mirrors' as mirrors;

void main(List<String> arguments) {
  var reflectedMyClass = mirrors.reflectType(mylib.MyClass);
  // how to list the methods in MyClass here?
}
1

There are 1 best solutions below

0
Dart Flutter On

Ok, mirrors.reflectClass(someClass).declarations.values is the answer. This stuff was not visible in the debugger window where I was stuck, but a null _declarations instead. Going through completions sometimes seems more helpful than the debugger.