Skip to content

PathMetric can get ripped out from under you. #27139

@dnfield

Description

@dnfield

The following code leads to a surprise:

  final Path path = Path()..lineTo(10, 0);
  final PathMetrics metrics = path.computeMetrics();
  final PathMetric metric = metrics.first;
  print(metric.length); // 10.0
  metrics.iterator.moveNext();
  print(metric.length); // 0.0 !!

This means things like metrics.toList() are very confusing. The length getter can probably be pretty easily fixed by making it less lazy (maybe force it to instantiate and store it on the Dart side at least when the iterator moves). The methods might be a bit more tricky - I think we'd need to expand out the full iteration on the C++ side and cache them for the lifetime of the object (if we should fix them at all).

At the very least, I think we should fix length (it's very confusing for a property to change like that) and document how the methods will work (if at all).

Metadata

Metadata

Assignees

Labels

d: api docsIssues with https://api.flutter.dev/engineflutter/engine related. See also e: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions