【发布时间】:2020-09-22 06:51:50
【问题描述】:
在生成的类中可以经常观察到美元符号。
类型也以$ 符号开头。我知道 Dart 语言允许类名包含美元符号,但也许它有一个我不知道的隐藏含义?我在 stackoverflow 上发现了类似的问题,但在 2012 年被问到,答案不再有效。
示例 1。
class Counter {
int _counter = 0;
int next() => ++_counter;
}
class Operation {
void operate(int step) { doSomething(); }
}
class $OperationWithCounter = Operation with Counter;
class Foo extends $OperationWithCounter{
void operate([int step]) {
super.operate(step ?? super.next());
}
【问题讨论】:
-
2018年同样的问题stackoverflow.com/questions/52729086/…
-
问题可能相同,但问题没有答案。答案中的链接不起作用。