initDeepLinks method

void initDeepLinks({
  1. void onLink(
    1. String path
    )?,
})

Initialize deep link handling.

Implementation

void initDeepLinks({void Function(String path)? onLink}) {
  _deepLinkSubscription?.cancel();
  _deepLinkSubscription = DeepLinkHandler.appLinks.uriLinkStream.listen(
    (uri) {
      final path = DeepLinkHandler._uriToPath(uri);
      if (onLink != null) {
        onLink(path);
      } else {
        try {
          useRouter().push(path);
        } catch (e) {
          debugPrint('DeepLinkMixin: Error navigating to $path: $e');
        }
      }
    },
  );
}