在Dart中获取NoSuchMethodError [英] Getting a NoSuchMethodError in Dart

查看:121
本文介绍了在Dart中获取NoSuchMethodError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Dart还是很陌生,我曾经使用过C#(通常是XNA),所以Dart有点不同,我不确定为什么会发生此错误。

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);

Position和canvasDimensions是我创建的一种类型,称为Vector2,它基本上包含两个数字x和y,我收到错误消息

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!

推荐答案

在这里 c.Position.x null 。在Dart中,对 null 调用方法(或您的情况下的运算符-)会导致 NoSuchMethodError

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

这篇关于在Dart中获取NoSuchMethodError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆