TrackPoint tp Type: TrackPoint
The argument type 'TrackPoint (where TrackPoint is defined in ...lib\trackpoint.dart)' can't be assigned to the parameter type 'TrackPoint (where TrackPoint is defined in ...lib\trackPoint.dart)'.dart (argument_type_not_assignable) trackpoint.dart(8, 7): TrackPoint is defined in ...lib\trackpoint.dart trackPoint.dart(8, 7): TrackPoint is defined in ...lib\trackPoint.dart
Here is where the error is:
import 'trackpoint.dart' show TrackPoint;
class TrackingStatus {
// ...
static void _triggerEvent(TrackPoint tp) {
// ...
TrackingStatusChangedEvent.trigger(tp); // <-- error on tp, see above
}
Here is what causes the error:
class TrackingStatusChangedEvent {
static void trigger(TrackPoint tp) { // <-- causes error
// ...
}
static void trigger(tp) { // <-- works but tp should not be dynamic
// ...
}
Here is where TrackPoint comes from:
class TrackPoint {
static final List<TrackPoint> _trackPoints = [];
void _addTrackPoint() {
_trackPoints.add(this);
argument_type_not_assignable is not reasonable for me. Especially because the error message points to the same class in the same file as if they are something different
CodePudding user response:
I recommend just using prefixes for library import. See below.
import 'trackpoint.dart' as tp;
Then use it like this.
class TrackPoint {
static final List<tp.TrackPoint> _trackPoints = [];
void _addTrackPoint() {
_trackPoints.add(this);
CodePudding user response:
Putting class TrackPoint and class TrackingStatus the same file solved the problem. May be it was a cross loading issue.
Thanks for your help anyway!