I see links to _internal in examples, for example:
class Symbol {
final String name;
static Map<String, Symbol> _cache;
factory Symbol(String name) {
if (_cache == null) {
_cache = {};
}
if (_cache.containsKey(name)) {
return _cache[name];
} else {
final symbol = new Symbol._internal(name);
_cache[name] = symbol;
return symbol;
}
}
Symbol._internal(this.name);
}
I realized from the code that this is a private accessible constructor. The last line Symbol._internal(this.name);seems a bit confusing because it looks like an operator inside the class body, not inside the method body, which makes me believe this definition of an internal constructor without the method body.
Are my assumptions correct?
source
share