flutter_mapbox_navigation icon indicating copy to clipboard operation
flutter_mapbox_navigation copied to clipboard

MapBoxNavigation directions returning null for remaining duration and distance

Open vpalcar opened this issue 2 years ago • 5 comments

On iOS MapBoxNavigation directions are returning null for the remaining duration and distance for embedded turn by turn navigation.

When I print the value of progress.distanceRemaining in the NavigationFactory.swift it returns correct values but I can’t find the way to access it on the dart side.

vpalcar avatar Jun 06 '22 03:06 vpalcar

Me too, in my OnRoutEvent I receive that my distanceRemaining and durationRemaining is null, I´m working with Android, after this I get an exception in the console image

lasd14 avatar Jun 07 '22 14:06 lasd14

@lasd14 this issue is probably the issue on the dart side. You are working with asynchronous methods and non-nullable variables so you might have forgotten to use await somewhere, therefore you are facing an issue above.

I have managed to solve the issue mentioned above on the native iOS side by saving progress.distanceRemaining and progress.durationRemaining (NavigationFactory.swift file) in global variables. Then I use these same variables in SwiftFlutterMapboxNavigationPlugin.swift to communicate it with Flutter.

Unfortunately, I am no iOS native developer myself and I think that this is far from good practice, therefore I will not make a PR for this issue but for now until this issue is not addressed it will make the job for my purposes.

vpalcar avatar Jun 07 '22 18:06 vpalcar

Thank you for your answer @vpalcar, I´ll check my code and try to fix the error

lasd14 avatar Jun 07 '22 19:06 lasd14

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type 'Null' is not a subtype of type 'FutureOr' E/flutter ( 6195): #0 MapBoxNavigation.distanceRemaining. package:flutter_mapbox_navigation/flutter_mapbox_navigation.dart:38 E/flutter ( 6195): #1 _rootRunUnary (dart:async/zone.dart:1434:47) E/flutter ( 6195): #2 _CustomZone.runUnary

Ashwani-Salaria avatar Jun 29 '22 18:06 Ashwani-Salaria

Flutter embeded mapbox navigation view widget MapBoxNavigationView() is not working. Even i have paste the example (https://pub.dev/packages/flutter_mapbox_navigation/example) code given in the package and also got the same error. I don't think that the example is also working. Please give some solution i am stuck here from last 2 months. E/flutter ( 7987): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type 'Null' is not a subtype of type 'FutureOr' E/flutter ( 7987): #0 MapBoxNavigationViewController.distanceRemaining. package:flutter_mapbox_navigation/embedded/controller.dart:30 E/flutter ( 7987): #1 _rootRunUnary (dart:async/zone.dart:1434:47) E/flutter ( 7987): #2 _CustomZone.runUnary (dart:async/zone.dart:1335:19) E/flutter ( 7987): E/flutter ( 7987): E/flutter ( 7987): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type 'Null' is not a subtype of type 'FutureOr' E/flutter ( 7987): #0 MapBoxNavigationViewController.durationRemaining. package:flutter_mapbox_navigation/embedded/controller.dart:35 E/flutter ( 7987): #1 _rootRunUnary (dart:async/zone.dart:1434:47) E/flutter ( 7987): #2 _CustomZone.runUnary (dart:async/zone.dart:1335:19)

anilguleria1988 avatar Jul 17 '22 10:07 anilguleria1988

This issue is resolved

eopeter avatar May 19 '23 11:05 eopeter