使用 flutter/dart vscode 显示 "method isn't defined" 当我在调用它之前检查特定的 mixin
Using flutter/dart vscode shows "method isn't defined" when i check for a specific mixin before calling it
这是我第一次弄乱 dart,我被这个愚蠢的错误困住了。我有 90% 的把握认为错误出在它的 vscode 部分,因为当 运行 应用时没有错误显示。
也许我以错误的方式解决了问题,我只是想在实现混合的对象中调用混合函数。例如,在 java 中,需要转换组件变量,但我无法在这种情况下进行转换。
代码
错误
The method 'onPanUpdate' isn't defined for the class 'Component'.
Try correcting the name to the name of an existing method, or defining a method named 'onPanUpdate'.
源代码
Maybe I'm approaching the problem in the wrong way, I simply want to call a mixin function in objects that implements the mixin. In java for example it would be required to cast the component variable, but I couldn't get cast to work in this situation.
要使其正常工作,必须使用以下代码来完成:
for (var component in this.components) {
if (component is PanDetector) {
(component as PanDetector).onPanUpdate(details);
}
}
特别感谢
这是我第一次弄乱 dart,我被这个愚蠢的错误困住了。我有 90% 的把握认为错误出在它的 vscode 部分,因为当 运行 应用时没有错误显示。
也许我以错误的方式解决了问题,我只是想在实现混合的对象中调用混合函数。例如,在 java 中,需要转换组件变量,但我无法在这种情况下进行转换。
代码
错误
The method 'onPanUpdate' isn't defined for the class 'Component'. Try correcting the name to the name of an existing method, or defining a method named 'onPanUpdate'.
源代码
Maybe I'm approaching the problem in the wrong way, I simply want to call a mixin function in objects that implements the mixin. In java for example it would be required to cast the component variable, but I couldn't get cast to work in this situation.
要使其正常工作,必须使用以下代码来完成:
for (var component in this.components) {
if (component is PanDetector) {
(component as PanDetector).onPanUpdate(details);
}
}
特别感谢