質問

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 :(

役に立ちましたか?

解決

You can use InstanceMirror.getField :

metadata.getField(#name);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top