flutter_mapbox_navigation
flutter_mapbox_navigation copied to clipboard
MapBoxNavigation directions returning null for remaining duration and distance
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.
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
@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.
Thank you for your answer @vpalcar, I´ll check my code and try to fix the error
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type 'Null' is not a subtype of type 'FutureOr
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
This issue is resolved