Reputation: 373
Dollar sign can be observed in generated classes very often.
Also types start there with $
sign. I know Dart language allows class names to contain dollar sign but maybe there is a hidden meaning of it which I am not aware of? I found similar question on stackoverflow but it was asked in 2012 and the answer is not valid any more.
Example 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());
}
Upvotes: 16
Views: 6364
Reputation: 71653
Dart identifiers can contain $
. It's just another letter to the language, but it is traditionally reserved for generated code. That allows code generators to (largely) avoid having to worry about naming conflicts as long as they put a $
somewhere in the names they create.
In this particular case, the name is simply intended to represent a synthetic name that did not occur in the original program. It was "generated" by the desugaring described where you found it.
Upvotes: 25