You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using is casting should work with variables out of the scope too. Here is an example:
finalA b =B(42);
voidmain() {
//This one doesn't allow compilation because//"The getter 'i' isn't defined for the type A" even though//the variable has been casted inside the `if (b is B)`if (b isB) {
print(b.i);
}
//Making a local scope reference of this variable works as expected.final _b = b;
if (_b isB) {
print(_b.i);
}
}
abstractclassA {}
classBextendsA {
finalint i;
B(this.i);
}
Tested this on the latest DartPad with null safety enabled.
The text was updated successfully, but these errors were encountered:
This is a general instance of this issue. We could promote final global variables (as opposed to fields), but only at the expense of breaking the symmetry between variables and getter/setter pairs. See here for a list of issues discussing possible approaches to making this easier to work with.
When using is casting should work with variables out of the scope too. Here is an example:
Tested this on the latest DartPad with null safety enabled.
The text was updated successfully, but these errors were encountered: