I am new to Dart and I have a question regarding casting.
I am trying to cast a MouseEvent.offset Point to a Point. I understand that int is not a subtype of double. So what is the correct way to coerce an int into a double without having to do something like:
Point p = event.offset;
Point<double> dp = new Point<double>(p.x + 0.0, p.y + 0.0);
As expected when I try to do something like:
double x = p.x as double;
an exception is thrown.
Any thoughts?
Thanks.
你可以打电话给Double。
p.x.toDouble()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.