0
votes

I want to create my own class named Point, but am running into issues with the interface of the same name in the html library. What am I missing that would get me out of the "already defined as interface" pickle?

class Point
{
//r is x
// g is the difference between x+y and 0
// b is y
  num r,g,b;
  Point(this.r, this.g, this.b);
...
}

Internal error: 'http://127.0.0.1:3030/C:/Users/.../Desktop/dart/workspace/projects/.../Point.dart': error: line 1 pos 7: 'Point' is already defined as interface class Point

1
possible duplicate of Duplicate Class in Dart - antony.trupe

1 Answers

1
votes

When importing the library that has the class/interface you want to reuse, qualify it with a prefix, which will force you to be explicit to use the original class, and will use the new class implicitly.

#import('dart:html', prefix:'html');

html.Point will use the point interface in html.
Point will use the class in your project/library.