I have a static field:
static final List<Provider> _providers = [
ESVAPI()
];
And the objects inside of it are constructed (with a call to the super class) to add themselves to other lists:
Provider(this.name, this.requiresKey, this._versions) {
Provider._foo.add(name);
}
When I try referencing the list foo within the class, before I reference the variable the objects are not initialized. For example:
static final List<Provider> _providers = [
ESVAPI(),
];
static final _foo = <String>[];
static final name = _foo[0];
The variable name will be null since the items in the list are not yet initialized. The ESVAPI object will not be initialized until I reference _providers. Even if I were to reference it, the variable name will remain null since it was already constructed with the null value.
Considering the variables are final and I know how many classes there are, it would not be difficult to simply type in the needed values, but being able to immediately initialize a list and all the values inside of it would prove useful in the future for different use cases. Is there any way to initialize the values in the static list when the the list is first instantiated?