문제

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