Skip to content

Commit

Permalink
fix no-element exception when href is absent
Browse files Browse the repository at this point in the history
Co-Authored-By: Arthur Miranda <[email protected]>
Co-Authored-By: Kirill Bychkov <[email protected]>
  • Loading branch information
3 people committed Mar 8, 2024
1 parent 5ab5dd0 commit dffce1e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/src/gpx_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,11 @@ class GpxReader {
final elm = iterator.current;

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

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

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

0 comments on commit dffce1e

Please sign in to comment.