嗨,我正在编写一个 Dart 应用程序,但出现错误:
type 'Screen' is not a subtype of type 'Screen' of 'function result'.
我真的不知道实际的错误是什么?
我的代码如下:
class CanvasManager {
Map<String, Screen> _canvases = new Map<String, Screen>();
CanvasManager (Map<String, CanvasElement> reqCanvas, int sizeX, int sizeY, bool fullscreen) {
reqCanvas.forEach((k,v) {
_canvases[k] = new Screen.create(v, sizeX, sizeY, fullscreen);
});
}
Screen getCanvas(String c) {
if (_canvases.containsKey(c)) {
return _canvases[c];
}
else throw "No such canvas with key ${c}";
}
}
出于某种原因,当我实例化该类时,我得到了错误。
需要注意Screen
的是我也创建了一个类。由于我完全感到困惑,我不知道它是否也会通过为您提供该课程来帮助您。它有点长,所以我会粘贴它: http: //pastebin.com/KvZ54yPe