setNewRoutePath method

  1. @override
Future<void> setNewRoutePath(
  1. SandboxedRoute configuration
)
override

Called by the Router when the Router.routeInformationProvider reports that a new route has been pushed to the application by the operating system.

Consider using a SynchronousFuture if the result can be computed synchronously, so that the Router does not need to wait for the next microtask to schedule a build.

Implementation

@override
Future<void> setNewRoutePath(SandboxedRoute configuration) async {
  if (configuration.type == RouteType.settings) {
    _showSettings = true;
    notifyListeners();
    return;
  }

  _showSettings = false;

  // Apply deep link state
  if (configuration.queryParameters['path'] case String id) {
    ref.read(selectedElementNotifierProvider.notifier).select(id);

    if (configuration.queryParameters['params'] case String params) {
      ref.read(paramsQueryProvider(id).notifier).applyDeeplink(params);
    }
  }

  if (configuration.queryParameters['global'] case String global) {
    ref.read(addonQueryProvider.notifier).applyDeeplink(global);
  }

  notifyListeners();
}