You could also use a getter? It will require you to set up all of the fields once, but after that, you can call the complete list of fields and iterate through that.
class Person{
final String _firstName;
final String _secondName;
Person(this._firstName,this._secondName);
String get hisName{
return _firstName;
}
}
class Player extends Person{
final int _shirtNumber;
Player(String _firstName,String _secondName,this._shirtNumber) : super(_firstName, _secondName);
List get everything{
final stuff=[_firstName,_secondName,_shirtNumber];
return stuff;
}
}
void main(List<String> arguments) {
final foo = Player('David','Beckham',7);
print(foo.everything);
for (final blah in foo.everything){
print(blah);
}
}