Reputation: 17
I've been following a tutorial on youtube for flutter. https://www.youtube.com/watch?v=Zv5T2C1oKus. I'm new to flutter and dart btw. I don't understand this error message.
lib/main.dart:91:36: Error: The value 'null' can't be assigned to the parameter type 'Offset' because 'Offset' is not nullable.
- 'Offset' is from 'dart:ui'. points.add(null); ^
here is my code
Upvotes: 0
Views: 1148
Reputation: 56
In the video you linked, there is a check whether points[x]
is null
, so I assume the elements of points
should be nullable. You can achieve this with
List<Offset?> points = [];
(instead of List<Offset> points = [];
).
The added questionmark makes it possible for elements of the list to be either a instance of the class Offset
or the value null
.
Upvotes: 4
Reputation: 166
The points is non-nullable list.
So this time, it can be solved with to remove points.add(null); inside onPanEnd. (Or add non-null Offset.)
Upvotes: 0