flutter_mapbox_navigation: The startNavigation method dont work
When using this plugin and following all the installation steps, it is impossible to register it correctly. It seems a compatibility issue. my pubspect.ymal and my implementation
`name: apppalermodev description: A new Flutter project. environment: sdk: “>=2.2.2 ❤️.0.0”
dependencies: flutter: sdk: flutter flutter_localizations: sdk: flutter flutter_cupertino_localizations: ^1.0.1 expandable: ^4.0.1 fluttertoast: ^3.1.3 english_words: ^3.1.3 cupertino_icons: ^0.1.2 flutter_socket_io: ^0.6.0 rxdart: ^0.22.2 device_info: ^0.4.0+3 shared_preferences: ^0.5.2 http: ^0.12.0+2 sqflite: ^1.1.5 path_provider: ^1.3.0 connectivity: ^0.4.2 encrypt: ^3.3.1 blue_thermal_printer: ^1.0.9 pull_to_refresh: ^1.4.5 image_picker: ^0.6.2+3 badges: ^1.1.0 progress_hud: ^1.1.0 carousel_slider: ^1.3.0 rflutter_alert: ^1.0.3 crypto: ^2.1.3 location: ^2.3.5 flutter_bcrypt: ^1.0.5 dbcrypt: ^1.0.0 flutter_speed_dial: ^1.2.5 flutter_map: ^0.8.2 latlong: ^0.6.1 bitmap: ^0.0.6 flutter_mapbox_navigation: ^0.0.8
dev_dependencies: flutter_test: sdk: flutter mapbox_gl: path: ./dependencies/flutter-mapbox-gl
module: androidX: true
flutter:
uses-material-design: true assets:
- media/
- assets/
- assets/symbols/
- assets/img/
- assets/img/modulos/
- lib/src/utils/languages/
fonts:
- family: CenturyGothic
fonts:
- asset: assets/fonts/CenturyGothicRegular.ttf `
` class MapReconexionState extends State<MapReconexion> { bool _arrived = false; double _distanceRemaining, _durationRemaining; bool _tilesLoaded = false; … @override void initState() { super.initState(); _copyTilesIntoPlace(); initPlatformState(); }
Future<void> initPlatformState() async { // If the widget was removed from the tree while the asynchronous platform // message was in flight, we want to discard the reply rather than calling // setState to update our non-existent appearance. if (!mounted) return;
_directions = mapbox.MapboxNavigation(onRouteProgress: (arrived) async {
_distanceRemaining = await _directions.distanceRemaining;
_durationRemaining = await _directions.durationRemaining;
setState(() {
_arrived = arrived;
});
if (arrived) await _directions.finishNavigation();
});
} … Future<void> turnOnNavigation ({String origenName, String targetName, LatLng origin, LatLng target}) async {
if (origin == null) {
await getLoaction();
}
final _origin = mapbox.Location(name: "City Hall", latitude: 42.886448, longitude: -78.878372);
final _destination = mapbox.Location(name: "Downtown Buffalo", latitude: 42.8866177, longitude: -78.8814924);
await _directions.startNavigation(
origin: _origin,
destination: _destination,
mode: mapbox.NavigationMode.drivingWithTraffic,
simulateRoute: true);
} … PopupMenu( title: “Empezar viaje”, onTap: () { turnOnNavigation(); }, icon: Icons.directions_car) … } ` My error
Exception has occurred. MissingPluginException (MissingPluginException(No implementation found for method startNavigation on channel flutter_mapbox_navigation))
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 22 (4 by maintainers)
Commits related to this issue
- workaround issue #13 — committed to jtpdev/flutter_mapbox_navigation by jtpdev 4 years ago
I have found a workaround for this
Navigate to com.dormmom.flutter_mapbox_navigation.FlutterMapboxNavigationPlugin file as shown below
add (act:Activity) as a initializer to the FlutterMapboxNavigationPlugin class
like this
class FlutterMapboxNavigationPlugin(act: Activity): FlutterPlugin, ActivityAware
add initializer in the class
pass registrar.activity() as argument to the FlutterMapboxNavigationPlugin Object
val instance = FlutterMapboxNavigationPlugin(registrar.activity())
add following line in private onAttachedToEngine function
And you are done
full code for FlutterMapboxNavigationPlugin file below
What is your exact flutter version. Please provide flutter doctor -v output