Skip to content

Commit

Permalink
Merge pull request #25 from arthurbcd/master
Browse files Browse the repository at this point in the history
fix no-element exception when href is absent
  • Loading branch information
kb0 committed Jan 15, 2024
2 parents d96aab0 + 8f46499 commit e1079c6
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 e1079c6

Please sign in to comment.