I know you might say this question was asked many times but all the answers did not help!

I'm using MapBox in my application, whenever I try to load the navigation screen I get this error

E/Mbgl-Mapbox(13566): java.lang.IllegalArgumentException: com.s.isa.developments.delivery: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.

I'm not using PendingIntent anywhere in my code, I'm using latest flutter 3.0.3 Made sure to run flutter pub upgrade and pub outdated before

I have added also to my app/build.gradle

    implementation("androidx.work:work-runtime-ktx:2.8.0-alpha01")

Here is full log and code

error trace:

Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
√  Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
Debug service listening on ws://127.0.0.1:65310/lqSN1cXp5UQ=/ws
Syncing files to device sdk gphone64 x86 64...
I/FirebaseApp(13836): Device unlocked: initializing all Firebase APIs for app [DEFAULT]
D/FirebaseAuth(13836): Notifying id token listeners about user ( NCgMi7YY2zcKg6VZLAeHjRUu7UW2 ).
W/FlutterJNI(13836): FlutterJNI.loadLibrary called more than once
I/ResourceExtractor(13836): Found extracted resources res_timestamp-4-1656151961357
W/FlutterJNI(13836): FlutterJNI.prefetchDefaultFontManager called more than once
W/FlutterJNI(13836): FlutterJNI.init called more than once
I/FLTFireBGExecutor(13836): Creating background FlutterEngine instance, with args: [--start-paused, --enable-dart-profiling]
D/EGL_emulation(13836): eglCreateContext: 0x78e1f29d9d10: maj 2 min 0 rcv 2
D/EGL_emulation(13836): eglCreateContext: 0x78e1f29da3d0: maj 2 min 0 rcv 2
D/HostConnection(13836): createUnique: call
D/HostConnection(13836): HostConnection::get() New Host Connection established 0x78e1f29dc890, tid 13921
D/HostConnection(13836): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2 
D/EGL_emulation(13836): eglMakeCurrent: 0x78e1f29da3d0: ver 2 0 (tinfo 0x78e408751280) (first time)
I/FLTFireMsgService(13836): FlutterFirebaseMessagingBackgroundService started!
W/CrashReporter(13836): Root directory doesn't exist
E/Mbgl-Mapbox(13836): Error occurred while initializing telemetry
E/Mbgl-Mapbox(13836): java.lang.IllegalArgumentException: com.s.isa.developments.delivery: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/Mbgl-Mapbox(13836): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
E/Mbgl-Mapbox(13836):   at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
E/Mbgl-Mapbox(13836):   at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
E/Mbgl-Mapbox(13836):   at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
E/Mbgl-Mapbox(13836):   at com.mapbox.android.telemetry.AlarmSchedulerFlusher.register(AlarmSchedulerFlusher.java:31)
E/Mbgl-Mapbox(13836):   at com.mapbox.android.telemetry.MapboxTelemetry.startAlarm(MapboxTelemetry.java:380)
E/Mbgl-Mapbox(13836):   at com.mapbox.android.telemetry.MapboxTelemetry.startTelemetry(MapboxTelemetry.java:374)
E/Mbgl-Mapbox(13836):   at com.mapbox.android.telemetry.MapboxTelemetry.enable(MapboxTelemetry.java:114)
E/Mbgl-Mapbox(13836):   at com.mapbox.mapboxsdk.module.telemetry.TelemetryImpl.<init>(TelemetryImpl.java:33)
E/Mbgl-Mapbox(13836):   at com.mapbox.mapboxsdk.ModuleProviderImpl.obtainTelemetry(ModuleProviderImpl.java:22)
E/Mbgl-Mapbox(13836):   at com.mapbox.mapboxsdk.Mapbox.initializeTelemetry(Mapbox.java:167)
E/Mbgl-Mapbox(13836):   at com.mapbox.mapboxsdk.Mapbox.getInstance(Mapbox.java:64)
E/Mbgl-Mapbox(13836):   at com.dormmom.flutter_mapbox_navigation.activity.NavigationActivity.onCreate(NavigationActivity.kt:78)
E/Mbgl-Mapbox(13836):   at android.app.Activity.performCreate(Activity.java:8051)
E/Mbgl-Mapbox(13836):   at android.app.Activity.performCreate(Activity.java:8031)
E/Mbgl-Mapbox(13836):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
E/Mbgl-Mapbox(13836):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3608)
E/Mbgl-Mapbox(13836):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3792)
E/Mbgl-Mapbox(13836):   at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
E/Mbgl-Mapbox(13836):   at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/Mbgl-Mapbox(13836):   at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/Mbgl-Mapbox(13836):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2210)
E/Mbgl-Mapbox(13836):   at android.os.Handler.dispatchMessage(Handler.java:106)
E/Mbgl-Mapbox(13836):   at android.os.Looper.loopOnce(Looper.java:201)
E/Mbgl-Mapbox(13836):   at android.os.Looper.loop(Looper.java:288)
E/Mbgl-Mapbox(13836):   at android.app.ActivityThread.main(ActivityThread.java:7839)
E/Mbgl-Mapbox(13836):   at java.lang.reflect.Method.invoke(Native Method)
E/Mbgl-Mapbox(13836):   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/Mbgl-Mapbox(13836):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
W/pments.deliver(13836): Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (unsupported, reflection, allowed)
W/pments.deliver(13836): Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (unsupported, reflection, allowed)
W/pments.deliver(13836): Accessing hidden field Landroid/graphics/Typeface;->sSystemFontMap:Ljava/util/Map; (unsupported, reflection, allowed)
I/Mbgl    (13836): {pments.delivery}[General]: Loaded Mapbox Common 9.1.0, built using 9.0.2.
W/pments.deliver(13836): Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (unsupported,core-platform-api, reflection, allowed)
W/pments.deliver(13836): Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (unsupported,core-platform-api, reflection, allowed)
W/pments.deliver(13836): Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (unsupported,core-platform-api, reflection, allowed)
W/BottomSheetBehavior(13836): BottomSheetBehavior now supports multiple callbacks. `setBottomSheetCallback()` removes all existing callbacks, including ones set internally by library authors, which may result in unintended behavior. This may change in the future. Please use `addBottomSheetCallback()` and `removeBottomSheetCallback()` instead to set your own callbacks.
I/Mbgl-EGLConfigChooser(13836): In emulator: false
D/HostConnection(13836): createUnique: call
D/HostConnection(13836): HostConnection::get() New Host Connection established 0x78e1f29db090, tid 13930
D/HostConnection(13836): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2 
D/EGL_emulation(13836): eglCreateContext: 0x78e1f29dad90: maj 2 min 0 rcv 2
D/EGL_emulation(13836): eglMakeCurrent: 0x78e1f29dad90: ver 2 0 (tinfo 0x78e408751300) (first time)
I/Mbgl    (13836): {GLThread 95}[General]: GPU Identifier: Android Emulator OpenGL ES Translator (NVIDIA GeForce RTX 3080 Ti/PCIe/SSE2)
V/Mbgl-ConnectivityReceiver(13836): connected - true
I/OnboardRouterFiles(13836): Initial size is 4096 bytes
I/pments.deliver(13836): Thread[1,tid=13836,Native,Thread*=0x78e2d29cb7b0,peer=0x72c916a0,"main"] recursive attempt to load library "/data/app/~~6yZaN91YYPM023yHZ9MccA==/com.s.isa.developments.delivery-KMNmtOheNTAP8tP1Qay0LA==/lib/x86_64/libmapbox-common.so"
E/MapboxNavNative(13836): User defined HTTP service instance not provided from the module implementation.
E/MapboxNavNative(13836): Module: com.mapbox.common.module.okhttp.MapboxOkHttpService@2a5c23f
E/MapboxNavNative(13836): but present is: com.mapbox.common.module.okhttp.MapboxOkHttpService@2a5c23f
E/MapboxNavNative(13836): Are you calling HttpServiceFactory.setUserDefined() correctly?
E/MapboxModuleProvider(13836): Module loading failed
E/MapboxModuleProvider(13836): java.lang.NoSuchMethodException: com.mapbox.navigation.trip.notification.internal.MapboxTripNotification.<init> []
E/MapboxModuleProvider(13836):  at java.lang.Class.getConstructor0(Class.java:2363)
E/MapboxModuleProvider(13836):  at java.lang.Class.getConstructor(Class.java:1759)
E/MapboxModuleProvider(13836):  at com.mapbox.common.module.provider.MapboxModuleProvider$noArgConstructorCreator$1.getInstance(MapboxModuleProvider.kt:107)
E/MapboxModuleProvider(13836):  at com.mapbox.common.module.provider.MapboxModuleProvider.createModule(MapboxModuleProvider.kt:69)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.core.MapboxNavigation.<init>(MapboxNavigation.kt:179)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.core.MapboxNavigationProvider.create(MapboxNavigationProvider.kt:23)
E/MapboxModuleProvider(13836):  at com.dormmom.flutter_mapbox_navigation.activity.NavigationActivity.fetchRoute(NavigationActivity.kt:107)
E/MapboxModuleProvider(13836):  at com.dormmom.flutter_mapbox_navigation.activity.NavigationActivity.onNavigationReady(NavigationActivity.kt:94)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.ui.NavigationView.updateNavigationReadyListeners(NavigationView.java:653)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.ui.NavigationView.access$700(NavigationView.java:75)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.ui.NavigationView$1.onStyleLoaded(NavigationView.java:247)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.MapboxMap.notifyStyleLoaded(MapboxMap.java:963)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.MapboxMap.onFinishLoadingStyle(MapboxMap.java:225)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.MapView$MapCallback.onDidFinishLoadingStyle(MapView.java:1375)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.MapChangeReceiver.onDidFinishLoadingStyle(MapChangeReceiver.java:198)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.NativeMapView.onDidFinishLoadingStyle(NativeMapView.java:1166)
E/MapboxModuleProvider(13836):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/MapboxModuleProvider(13836):  at android.os.MessageQueue.next(MessageQueue.java:335)
E/MapboxModuleProvider(13836):  at android.os.Looper.loopOnce(Looper.java:161)
E/MapboxModuleProvider(13836):  at android.os.Looper.loop(Looper.java:288)
E/MapboxModuleProvider(13836):  at android.app.ActivityThread.main(ActivityThread.java:7839)
E/MapboxModuleProvider(13836):  at java.lang.reflect.Method.invoke(Native Method)
E/MapboxModuleProvider(13836):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/MapboxModuleProvider(13836):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
E/MapboxModuleProvider(13836): Module loading failed
E/MapboxModuleProvider(13836): java.lang.NoSuchFieldException: INSTANCE
E/MapboxModuleProvider(13836):  at java.lang.Class.getField(Class.java:1635)
E/MapboxModuleProvider(13836):  at com.mapbox.common.module.provider.MapboxModuleProvider$kotlinObjectReferenceProvider$1.getInstance(MapboxModuleProvider.kt:117)
E/MapboxModuleProvider(13836):  at com.mapbox.common.module.provider.MapboxModuleProvider.createModule(MapboxModuleProvider.kt:69)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.core.MapboxNavigation.<init>(MapboxNavigation.kt:179)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.core.MapboxNavigationProvider.create(MapboxNavigationProvider.kt:23)
E/MapboxModuleProvider(13836):  at com.dormmom.flutter_mapbox_navigation.activity.NavigationActivity.fetchRoute(NavigationActivity.kt:107)
E/MapboxModuleProvider(13836):  at com.dormmom.flutter_mapbox_navigation.activity.NavigationActivity.onNavigationReady(NavigationActivity.kt:94)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.ui.NavigationView.updateNavigationReadyListeners(NavigationView.java:653)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.ui.NavigationView.access$700(NavigationView.java:75)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.ui.NavigationView$1.onStyleLoaded(NavigationView.java:247)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.MapboxMap.notifyStyleLoaded(MapboxMap.java:963)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.MapboxMap.onFinishLoadingStyle(MapboxMap.java:225)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.MapView$MapCallback.onDidFinishLoadingStyle(MapView.java:1375)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.MapChangeReceiver.onDidFinishLoadingStyle(MapChangeReceiver.java:198)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.NativeMapView.onDidFinishLoadingStyle(NativeMapView.java:1166)
E/MapboxModuleProvider(13836):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/MapboxModuleProvider(13836):  at android.os.MessageQueue.next(MessageQueue.java:335)
E/MapboxModuleProvider(13836):  at android.os.Looper.loopOnce(Looper.java:161)
E/MapboxModuleProvider(13836):  at android.os.Looper.loop(Looper.java:288)
E/MapboxModuleProvider(13836):  at android.app.ActivityThread.main(ActivityThread.java:7839)
E/MapboxModuleProvider(13836):  at java.lang.reflect.Method.invoke(Native Method)
E/MapboxModuleProvider(13836):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/MapboxModuleProvider(13836):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
E/MapboxModuleProvider(13836): Module loading failed
E/MapboxModuleProvider(13836): java.lang.NoSuchMethodException: com.mapbox.navigation.trip.notification.internal.MapboxTripNotification.getInstance []
E/MapboxModuleProvider(13836):  at java.lang.Class.getMethod(Class.java:2103)
E/MapboxModuleProvider(13836):  at java.lang.Class.getMethod(Class.java:1724)
E/MapboxModuleProvider(13836):  at com.mapbox.common.module.provider.MapboxModuleProvider$singletonReferenceProvider$1.getInstance(MapboxModuleProvider.kt:126)
E/MapboxModuleProvider(13836):  at com.mapbox.common.module.provider.MapboxModuleProvider.createModule(MapboxModuleProvider.kt:69)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.core.MapboxNavigation.<init>(MapboxNavigation.kt:179)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.core.MapboxNavigationProvider.create(MapboxNavigationProvider.kt:23)
E/MapboxModuleProvider(13836):  at com.dormmom.flutter_mapbox_navigation.activity.NavigationActivity.fetchRoute(NavigationActivity.kt:107)
E/MapboxModuleProvider(13836):  at com.dormmom.flutter_mapbox_navigation.activity.NavigationActivity.onNavigationReady(NavigationActivity.kt:94)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.ui.NavigationView.updateNavigationReadyListeners(NavigationView.java:653)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.ui.NavigationView.access$700(NavigationView.java:75)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.ui.NavigationView$1.onStyleLoaded(NavigationView.java:247)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.MapboxMap.notifyStyleLoaded(MapboxMap.java:963)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.MapboxMap.onFinishLoadingStyle(MapboxMap.java:225)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.MapView$MapCallback.onDidFinishLoadingStyle(MapView.java:1375)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.MapChangeReceiver.onDidFinishLoadingStyle(MapChangeReceiver.java:198)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.NativeMapView.onDidFinishLoadingStyle(NativeMapView.java:1166)
E/MapboxModuleProvider(13836):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/MapboxModuleProvider(13836):  at android.os.MessageQueue.next(MessageQueue.java:335)
E/MapboxModuleProvider(13836):  at android.os.Looper.loopOnce(Looper.java:161)
E/MapboxModuleProvider(13836):  at android.os.Looper.loop(Looper.java:288)
E/MapboxModuleProvider(13836):  at android.app.ActivityThread.main(ActivityThread.java:7839)
E/MapboxModuleProvider(13836):  at java.lang.reflect.Method.invoke(Native Method)
E/MapboxModuleProvider(13836):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/MapboxModuleProvider(13836):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
E/MapboxModuleProvider(13836): Module loading failed
E/MapboxModuleProvider(13836): java.lang.reflect.InvocationTargetException
E/MapboxModuleProvider(13836):  at java.lang.reflect.Constructor.newInstance0(Native Method)
E/MapboxModuleProvider(13836):  at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
E/MapboxModuleProvider(13836):  at com.mapbox.common.module.provider.MapboxModuleProvider$defaultMapboxModuleCreator$1.getInstance(MapboxModuleProvider.kt:138)
E/MapboxModuleProvider(13836):  at com.mapbox.common.module.provider.MapboxModuleProvider.createModule(MapboxModuleProvider.kt:69)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.core.MapboxNavigation.<init>(MapboxNavigation.kt:179)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.core.MapboxNavigationProvider.create(MapboxNavigationProvider.kt:23)
E/MapboxModuleProvider(13836):  at com.dormmom.flutter_mapbox_navigation.activity.NavigationActivity.fetchRoute(NavigationActivity.kt:107)
E/MapboxModuleProvider(13836):  at com.dormmom.flutter_mapbox_navigation.activity.NavigationActivity.onNavigationReady(NavigationActivity.kt:94)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.ui.NavigationView.updateNavigationReadyListeners(NavigationView.java:653)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.ui.NavigationView.access$700(NavigationView.java:75)
E/MapboxModuleProvider(13836):  at com.mapbox.navigation.ui.NavigationView$1.onStyleLoaded(NavigationView.java:247)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.MapboxMap.notifyStyleLoaded(MapboxMap.java:963)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.MapboxMap.onFinishLoadingStyle(MapboxMap.java:225)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.MapView$MapCallback.onDidFinishLoadingStyle(MapView.java:1375)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.MapChangeReceiver.onDidFinishLoadingStyle(MapChangeReceiver.java:198)
E/MapboxModuleProvider(13836):  at com.mapbox.mapboxsdk.maps.NativeMapView.onDidFinishLoadingStyle(NativeMapView.java:1166)
E/MapboxModuleProvider(13836):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/MapboxModuleProvider(13836):  at android.os.MessageQueue.next(MessageQueue.java:335)
E/MapboxModuleProvider(13836):  at android.os.Looper.loopOnce(Looper.java:161)
E/MapboxModuleProvider(13836):  at android.os.Looper.loop(Looper.java:288)
E/MapboxModuleProvider(13836):  at android.app.ActivityThread.main(ActivityThread.java:7839)
E/MapboxModuleProvider(13836):  at java.lang.reflect.Method.invoke(Native Method)
E/MapboxModuleProvider(13836):  at ...
Lost connection to device.

Navigation class:

import 'package:delivery/components.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mapbox_navigation/library.dart';

class Drive extends StatefulWidget {
  List<Package> packages = [];
  Drive({Key? key, List<Package>? packages}) : super(key: key);

  @override
  State<Drive> createState() => _DriveState();
}

class _DriveState extends State<Drive> {
  var waypoints = <WayPoint>[];
  final _origin = WayPoint(
      name: "Way Point 1",
      latitude: 38.9111117447887,
      longitude: -77.04012393951416);
  final _stop1 = WayPoint(
      name: "Way Point 2",
      latitude: 38.91113678979344,
      longitude: -77.03847169876099);
  final _stop2 = WayPoint(
      name: "Way Point 3",
      latitude: 38.91040213277608,
      longitude: -77.03848242759705);
  final _stop3 = WayPoint(
      name: "Way Point 4",
      latitude: 38.909650771013034,
      longitude: -77.03850388526917);
  final _stop4 = WayPoint(
      name: "Way Point 5",
      latitude: 38.90894949285854,
      longitude: -77.03651905059814);

  // Config variables for Mapbox Navigation
  late MapBoxNavigation directions;
  late MapBoxOptions _options;
  late double distanceRemaining, durationRemaining;
  late MapBoxNavigationViewController _controller;
  final bool isMultipleStop = false;
  String instruction = "";
  bool arrived = false;
  bool routeBuilt = false;
  bool isNavigating = false;

  @override
  void initState() {
    super.initState();
    initialize();
  }

  Future<void> initialize() async {
    if (!mounted) return;

    // Setup directions and options
    directions = MapBoxNavigation(onRouteEvent: _onRouteEvent);
    _options = MapBoxOptions(
        zoom: 18.0,
        voiceInstructionsEnabled: true,
        bannerInstructionsEnabled: true,
        mode: MapBoxNavigationMode.drivingWithTraffic,
        isOptimized: true,
        units: VoiceUnits.metric,
        simulateRoute: true,
        language: "en");

    // Configure waypoints
    waypoints.add(_origin);
    waypoints.add(_stop1);
    waypoints.add(_stop2);
    waypoints.add(_stop3);
    waypoints.add(_stop4);

    // Start the trip
    await directions.startNavigation(wayPoints: waypoints, options: _options);
  }

  Future<void> _onRouteEvent(e) async {
    distanceRemaining = await directions.distanceRemaining;
    durationRemaining = await directions.durationRemaining;

    switch (e.eventType) {
      case MapBoxEvent.progress_change:
        var progressEvent = e.data as RouteProgressEvent;
        arrived = progressEvent.arrived!;
        if (progressEvent.currentStepInstruction != null) {
          instruction = progressEvent.currentStepInstruction!;
        }
        break;
      case MapBoxEvent.route_building:
      case MapBoxEvent.route_built:
        routeBuilt = true;
        break;
      case MapBoxEvent.route_build_failed:
        routeBuilt = false;
        break;
      case MapBoxEvent.navigation_running:
        isNavigating = true;
        break;
      case MapBoxEvent.on_arrival:
        arrived = true;
        if (!isMultipleStop) {
          await Future.delayed(const Duration(seconds: 3));
          await _controller.finishNavigation();
        } else {}
        break;
      case MapBoxEvent.navigation_finished:
      case MapBoxEvent.navigation_cancelled:
        routeBuilt = false;
        isNavigating = false;
        break;
      default:
        break;
    }
    //refresh UI
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Text('drive'),
    );
  }
}

pubspec.yml

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

  flash: ^2.0.3+1
  sizer: ^2.0.15
  flutter_svg: ^1.0.0
  google_fonts: ^3.0.1
  shared_preferences: ^2.0.11
  provider: ^6.0.1
  font_awesome_flutter: ^10.1.0
  loader_overlay: ^2.0.5
  firebase_core: ^1.10.6
  cloud_firestore: ^3.1.5
  firebase_auth: ^3.3.4
  flutter_secure_storage: ^5.0.2
  loading_indicator: ^3.0.2
  curved_navigation_bar: ^1.0.1
  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  flutter_phone_direct_caller: ^2.1.0
  firebase_messaging: ^11.2.8
  persian_number_utility: ^1.1.1
  google_mobile_ads: ^1.1.0
  flutter_local_notifications: ^9.4.1
  currency_text_input_formatter: ^2.1.5
  flutter_device_type: ^0.4.0
  simple_animations: ^4.0.2
  url_launcher: ^6.1.2
  whatsapp_unilink: ^2.0.1+1
  modal_bottom_sheet: ^2.0.1
  readmore: ^2.1.0
  flutter_mapbox_navigation: ^0.0.26

I have spent too many hours on this already and tried many work-runtime versions but nothing worked for me!

Thanks in advance!

0

There are 0 answers