Maybe this is not a Dart
specific question.
I have :
class A {
int a;
A(this.a);
}
class B extends A {
String b;
B(a, this.b) : super(a);
}
So you see, class A
has an attribute int a
and B
just extends A
and has an extra attribute String b
and a wrapper class C
:
class C {
A c;
C(this.c);
void doSomething() {
if (c is B) {
print(c.b);
} else {
print(c.a);
}
}
}
The Dart Editor complaints that the c doesn't have a getter b
. How do you deal with this? I want to get rid the warning, but I don't want to add attribute b
to class A