Getting a NoSuchMethodError in Dart

半腔热情 提交于 2019-12-01 22:58:50

问题


I'm pretty new to Dart, and I'm used to working with C# (and XNA usually), so Dart is a little different, and I'm not sure why this error is happening.

double left = c.Position.x - (canvasDimensions.x * 0.5);

the Position and canvasDimensions are a type I created, called Vector2, which basically contains 2 numbers, x and y, I am getting the error

NoSuchMethodError : method not found: '-'
Receiver: null
Arguments: [600.0]

on the line shown, since I am not familiar with the language I am not sure why this is happening, please help, thanks!


回答1:


Here c.Position.x is null. In Dart calling a method (or an operator - in your case) on null leads to a NoSuchMethodError.



来源:https://stackoverflow.com/questions/14530799/getting-a-nosuchmethoderror-in-dart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!