Skip to content

Commit

Permalink
Updated return-type for PathMetric.extractPath to be non-nullable (fl…
Browse files Browse the repository at this point in the history
  • Loading branch information
sarbagyastha authored Nov 4, 2020
1 parent acc2466 commit deb7c66
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ Dwayne Slater <[email protected]>
Tetsuhiro Ueda <[email protected]>
shoryukenn <[email protected]>
SOTEC GmbH & Co. KG <[email protected]>
Hidenori Matsubayashi <[email protected]>
Hidenori Matsubayashi <[email protected]>
Sarbagya Dhaubanjar <[email protected]>
5 changes: 2 additions & 3 deletions lib/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2744,12 +2744,11 @@ class PathMetric {
return _measure.getTangentForOffset(contourIndex, distance);
}

/// Given a start and stop distance, return the intervening segment(s).
/// Given a start and end distance, return the intervening segment(s).
///
/// `start` and `end` are clamped to legal values (0..[length])
/// Returns null if the segment is 0 length or `start` > `stop`.
/// Begin the segment with a moveTo if `startWithMoveTo` is true.
Path? extractPath(double start, double end, {bool startWithMoveTo = true}) {
Path extractPath(double start, double end, {bool startWithMoveTo = true}) {
return _measure.extractPath(contourIndex, start, end, startWithMoveTo: startWithMoveTo);
}

Expand Down
16 changes: 7 additions & 9 deletions lib/web_ui/lib/src/engine/html/path/path_metrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class _SurfacePathMeasure {
return true;
}

ui.Path? extractPath(int contourIndex, double start, double end,
ui.Path extractPath(int contourIndex, double start, double end,
{bool startWithMoveTo = true}) {
return _contours[contourIndex].extractPath(start, end, startWithMoveTo);
}
Expand Down Expand Up @@ -196,22 +196,22 @@ class _PathContourMeasure {
return segment.computeTangent(t);
}

ui.Path? extractPath(
ui.Path extractPath(
double startDistance, double stopDistance, bool startWithMoveTo) {
if (startDistance < 0) {
startDistance = 0;
}
if (stopDistance > _contourLength) {
stopDistance = _contourLength;
}
final ui.Path path = ui.Path();
if (startDistance > stopDistance || _segments.isEmpty) {
return null;
return path;
}
final ui.Path path = ui.Path();
int startSegmentIndex = _segmentIndexAtDistance(startDistance);
int stopSegmentIndex = _segmentIndexAtDistance(stopDistance);
if (startSegmentIndex == -1 || stopSegmentIndex == -1) {
return null;
return path;
}
int currentSegmentIndex = startSegmentIndex;
_PathSegment seg = _segments[currentSegmentIndex];
Expand Down Expand Up @@ -574,13 +574,11 @@ class SurfacePathMetric implements ui.PathMetric {
return _measure.getTangentForOffset(contourIndex, distance);
}

/// Given a start and stop distance, return the intervening segment(s).
/// Given a start and end distance, return the intervening segment(s).
///
/// `start` and `end` are pinned to legal values (0..[length])
/// Returns null if the segment is 0 length or `start` > `stop`.
/// Begin the segment with a moveTo if `startWithMoveTo` is true.
ui.Path? extractPath(double start, double end,
{bool startWithMoveTo = true}) {
ui.Path extractPath(double start, double end, {bool startWithMoveTo = true}) {
return _measure.extractPath(contourIndex, start, end,
startWithMoveTo: startWithMoveTo);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/ui/path_metrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class PathMetric {
double get length;
int get contourIndex;
Tangent? getTangentForOffset(double distance);
Path? extractPath(double start, double end, {bool startWithMoveTo = true});
Path extractPath(double start, double end, {bool startWithMoveTo = true});
bool get isClosed;
}

Expand Down

0 comments on commit deb7c66

Please sign in to comment.