Skip to content

Commit

Permalink
fix no-element exception when href is absent
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurbcd committed Jan 11, 2024
1 parent d96aab0 commit 8f46499
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/src/gpx_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,11 @@ class GpxReader {
final elm = iterator.current;

if (elm is XmlStartElementEvent) {
link.href = elm.attributes
.firstWhere((attr) => attr.name == GpxTagV11.href)
.value;
final hrefs = elm.attributes.where((attr) => attr.name == GpxTagV11.href);

if (hrefs.isNotEmpty) {
link.href = hrefs.first.value;
}
}

if ((elm is XmlStartElementEvent) && !elm.isSelfClosing) {
Expand Down

0 comments on commit 8f46499

Please sign in to comment.