在dart:mirrors包中,从符号获取字符串值的方法是:
MirrorSystem.getName(#MySymbol);
是否有对应的可反射包?
这可能是你想要的,但它不像MirrorSystem.getName(#MySymbol);
那样通用
library some_lib;
//import 'dart:mirrors' as mirr;
import 'package:reflectable/reflectable.dart';
class Reflector extends Reflectable {
const Reflector() : super(typeCapability);
}
const Reflector reflector = const Reflector();
main() {
// print(mirr.MirrorSystem.getName(#SomeClass));
reflector.libraries.values.forEach((LibraryMirror lm) {
if (lm.declarations.containsKey('SomeClass')) {
print(lm.declarations['SomeClass']);
}
});
}
@reflector
class SomeClass {}