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

Flutter Mapbox navigation auto exit after navigation done #389

Open
Byte-Builders24 opened this issue Jan 8, 2025 · 0 comments
Open

Flutter Mapbox navigation auto exit after navigation done #389

Byte-Builders24 opened this issue Jan 8, 2025 · 0 comments

Comments

@Byte-Builders24
Copy link

Is there is a way to automatically navigate another screen when user reached to the location without showing this end navigation screen. Its only goto next screen after clicked end navigation. I want to do this automatically

Simulator Screenshot - iPhone 15 Pro - 2025-01-08 at 11 08 03

Future _onEmbeddedRouteEvent(e) async {
_distanceRemaining = await MapBoxNavigation.instance.getDistanceRemaining();
_durationRemaining = await MapBoxNavigation.instance.getDurationRemaining();

switch (e.eventType) {
  case MapBoxEvent.progress_change:
    var progressEvent = e.data as RouteProgressEvent;
    if (progressEvent.currentStepInstruction != null) {
      _instruction = progressEvent.currentStepInstruction;
    }
    break;
  case MapBoxEvent.route_building:
  case MapBoxEvent.route_built:
    setState(() {
      _routeBuilt = true;
    });
    break;
  case MapBoxEvent.route_build_failed:
    setState(() {
      _routeBuilt = false;
    });
    break;
  case MapBoxEvent.navigation_running:
    setState(() {
      _isNavigating = true;
    });
    break;
  case MapBoxEvent.on_arrival:
    if (!_isMultipleStop) {
      await Future.delayed(const Duration(seconds: 3));
      await _controller?.finishNavigation();

     
    } else {}
    break;
  case MapBoxEvent.navigation_finished:
    await _controller?.finishNavigation();

    Map<String, dynamic> nearestGateData = await findNearestGate();
    Navigator.push(
        context,
        MaterialPageRoute(
            builder: (context) => NavigationScreen(


                )));

    break;
  case MapBoxEvent.navigation_cancelled:
    setState(() {
      _routeBuilt = false;
      _isNavigating = false;
    });
    break;
  default:
    break;
}
setState(() {});

}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant