I looked at the dart:mirrors library, and I found ClassMirror. While I saw getField
I didn't see access to all fields. I did see getters
, though.
If I want to get all fields for a class, do I have to go through getters
?
I looked at the dart:mirrors library, and I found ClassMirror. While I saw getField
I didn't see access to all fields. I did see getters
, though.
If I want to get all fields for a class, do I have to go through getters
?
No, you should go through
ClassMirror.variables
:This will output:
ClassMirror.getters
would only returnb
andc
.Zdeslav Vojkovic's answer is a bit old.
This works for me, for Dart 1.1.3, as of March 2 2014.
Would output: