1

Dart code:

@Table("users")
class User {}

And the metadata declaration:

class Table {
    final String name;
    const Table(this.name);
}

I can get the metadata @Table by following code:

var classMirror = reflectClass(User);
var metadata = classMirror.metadata;
print(metadata);

Which prints:

[InstanceMirror on Instance of 'Table']

But I don't know how to get the users from it :(

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
Freewind
  • 193,756
  • 157
  • 432
  • 708

1 Answers1

3

You can use InstanceMirror.getField :

metadata.getField(#name);
Alexandre Ardhuin
  • 71,959
  • 15
  • 151
  • 132