The issue with your code is that you're trying to assign a value to
value1A
directly in the class body of
B
. In Dart, you can’t assign values to inherited variables directly in the class body. You should do this inside a method or constructor.
class A {
String? value1A;
A({
this.value1A,
});
}
class B extends A {
String value1B = "";
B() {
value1A = "";
}
}