Answer the question
In order to leave comments, you need to log in
How to change data in parents?
How to change the data in the parent?
I try like this:
parent.dart
class Parent{
int testText = 1;
}
class Child extends Parent{
open(){
@Output()
int testText = 2;
}
}
Answer the question
In order to leave comments, you need to log in
You create a variable in the open method int testText = 2;
.
To change the values in the parent - just write testText = 2;
.
If you want to change the values while having a local testText in the method:
class Child extends Parent{
open(){
@Output()
int testText = 2;
this.testText = 2;
// Присвоит значение в переменную у класса, а не в созданную выше.
// В данном случае у родителя из-за наследования.
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question