import 'package:reflection_test2/common/reflect/Reflector.dart';
@reflector
class Base
{
String s1;
}
@reflector
class Sub extends Base
{
String s2;
}
ClassMirror classMirror = reflector.reflectType(Sub);
=> Here classMirror reflects only s2, not reflecting base/super class member s1.
Not sure what exactly you need to do with s1
field, but one way to access it is listed below.
I hope it helps.
class Reflector extends Reflectable {
// config reflect capabilities
const Reflector() : super(invokingCapability, declarationsCapability, typeRelationsCapability);
}
ClassMirror classMirror = reflector.reflectType(Sub);
// print all instance members of the superclass (e.g. toString, s1, etc.)
classMirror.superclass.instanceMembers.forEach((key, value) => print(value.simpleName));