Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RangeError (index): Index out of range: no indices are valid: 0 on GeoJsonFeatureCollection.toJson if empty collection is returned from OpenRouteService #21

Closed
miklcct opened this issue Apr 3, 2024 · 2 comments · Fixed by #22
Assignees
Labels
bug Something isn't working

Comments

@miklcct
Copy link

miklcct commented Apr 3, 2024

GeoJsonFeatureCollection.toJson() does not work if the collection is empty from OpenRouteService.

import 'package:open_route_service/open_route_service.dart';

final openRouteService = OpenRouteService(apiKey: 'my_api_key');

void main() async {
  print((await openRouteService.geocodeAutoCompleteGet(text: 'skhfdkashfdkjashfdjs')).toJson());
}

Error:

Unhandled exception:
RangeError (index): Invalid value: Valid value range is empty: 0
#0      List.[] (dart:core-patch/growable_array.dart:264:36)
#1      GeoJsonFeatureCollection.toJson (package:open_route_service/src/models/geojson_feature_models.dart:57:15)
#2      main (file:///C:/Users/Michael/projects/test.dart:6:87)
<asynchronous suspension>
@Dhi13man
Copy link
Owner

Dhi13man commented Apr 5, 2024

Please review #22. Should fix this. Also contains Unit Tests to verify this and other empty cases.

@Dhi13man Dhi13man self-assigned this Apr 5, 2024
@Dhi13man Dhi13man added the bug Something isn't working label Apr 5, 2024
@Dhi13man
Copy link
Owner

Fixed in version Release #1.2.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants