Answer the question
In order to leave comments, you need to log in
How do constants work in dart?
Hello. I have code like this: "class Permission{
final String name;
const Permission(this.name);
}
class ReaderPermisssion extends Permission{
const ReaderPermisssion(String name):super(name);
static final ReaderPermisssion ALLOW_READ = const ReaderPermisssion("ALLOW_READ ");
}
class AdminPermission extends Permission{
const AdminPermission(String name):super(name);
static final AdminPermission ALLOW_WRITE = const AdminPermission("ALLOW_WRITE");
}
main(){
}
"
--------- -------------------------------------------------
Explain why the field constants: ALLOW_WRITE and ALLOW_READ are not themselves contained
? -Because of static, they are basically not class fields.
Answer the question
In order to leave comments, you need to log in
I barely understood what you want.
cosnt is a compile-time constant.
That is, it is immediately available with apk.
In ALLOW_WRITE you have an instance of the AdminPermission class . It has a name field , but no ALLOW_WRITE field .
And where does it come from, the same value for name .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question