I know, this question is very similar to DART find all the fields in class. I wonder if there is any way to achieve this without using mirrors?
My use case is the following: I use the shared_preferences package to store many values. For the keys I have a class like this:
class Key {
static const String FOO = 'foo';
static const String BAR = 'bar';
...
}
I want to write a unit test that checks, that this class of constants does not contains any duplicates. The following would leed to bugs:
class Key {
static const String FOO = 'foo';
static const String BAR = 'bar';
static const String ANOTHER = 'foo';
}
Since dart:mirrors
does not work here, what is the best way to implement the test?
Aucun commentaire:
Enregistrer un commentaire