Dart extends Map to facilitate lazy loading
问题 I am trying to lazy-load data from the server into a Map. For that reason I would like to add functionality to Map, so that when a key doesn't exist, a call is done to get the value . What I tried is this: class LazyMap extends Map { // use .length for now. When this works, go use xhr operator [](key) => LazyMap.putIfAbsent(key, () => key.length); } LazyMap test = new LazyMap(); main() { print(test.containsKey('hallo')); // false // I prefer to use this terse syntax and not have to use