end method
Ends the active path at the given point
.
This method finalizes the path segments and handles cases for very short paths (dots or single lines).
point
The final Offset for the path.
pressure
The pressure at the final point.
Returns true
if the path was successfully ended and is valid, false
otherwise.
Implementation
bool end({Offset? point, double? pressure}) {
if (point != null) {
add(point, pressure: pressure);
}
if (_points.isEmpty) {
return false;
}
if (_points.length < 3) {
if (_points.length == 1 || _points[0].distanceTo(points[1]) == 0.0) {
_addDot(CubicLine(
start: _points[0],
cpStart: _points[0],
cpEnd: _points[0],
end: _points[0],
));
} else {
_addLine(CubicLine(
start: _points[0],
cpStart: _points[0],
cpEnd: _points[1],
end: _points[1],
));
}
} else {
final i = _points.length - 3;
if (_points[i + 1].distanceTo(points[i + 2]) > 0.0) {
_addLine(CubicLine(
start: _points[i + 1],
cpStart: _points[i + 1],
cpEnd: _points[i + 2],
end: _points[i + 2],
));
}
}
return true;
}