Skip to content

Commit

Permalink
fix: error when lerping NaN points
Browse files Browse the repository at this point in the history
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'dart:ui/lerp.dart': Failed assertion: line 19 pos 10: '<optimized out>': Cannot interpolate between finite and non-finite values
#0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2      lerpDouble (dart:ui/lerp.dart:19:10)
#3      PointVector.lerp (package:perfect_freehand/src/types/point_vector.dart:54:7)
#4      getStrokeOutlinePoints (package:perfect_freehand/src/get_stroke_outline_points.dart:238:31)
#5      getStroke (package:perfect_freehand/src/get_stroke.dart:19:10)
#6      Stroke._getPolygon (package:saber/components/canvas/_stroke.dart:200:21)
#7      Stroke._updatePolygon (package:saber/components/canvas/_stroke.dart:48:16)
#8      Stroke.polygon (package:saber/components/canvas/_stroke.dart:38:32)
steveruizok#9      Stroke.toSvgPath (package:saber/components/canvas/_stroke.dart:247:9)
steveruizok#10     EditorExporter.generatePdf.<anonymous closure>.<anonymous closure> (package:saber/data/editor/editor_exporter.dart:111:52)
steveruizok#11     CustomPaint.paint (package:pdf/src/widgets/basic.dart:623:25)
steveruizok#12     SingleChildWidget.paintChild (package:pdf/src/widgets/widget.dart:320:14)
steveruizok#13     ConstrainedBox.paint (package:pdf/src/widgets/basic.dart:449:5)
steveruizok#14     StatelessWidget.paint (package:pdf/src/widgets/widget.dart:260:15)
steveruizok#15     Page.paint (package:pdf/src/widgets/page.dart:246:13)
steveruizok#16     Page.postProcess (package:pdf/src/widgets/page.dart:179:5)
steveruizok#17     Document.save (package:pdf/src/widgets/document.dart:130:14)
steveruizok#18     EditorState.exportAsPdf (package:saber/pages/editor/editor.dart:1213:72)
<asynchronous suspension>
steveruizok#19     _ExportBarState._onPressed.<anonymous closure>.<anonymous closure> (package:saber/components/toolbar/export_bar.dart:38:29)
<asynchronous suspension>
  • Loading branch information
adil192 committed Feb 6, 2024
1 parent 6bd2a87 commit 199ffce
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/src/types/point_vector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class PointVector extends Offset {
double t,
PointVector other,
) {
// avoid null values
if (!isFinite) return other;
if (!other.isFinite) return this;

return PointVector(
lerpDouble(x, other.x, t)!,
lerpDouble(y, other.y, t)!,
Expand Down

0 comments on commit 199ffce

Please sign in to comment.