initPlatformStateForUriUniLinks method

Future<void> initPlatformStateForUriUniLinks()

Implementation

Future<void> initPlatformStateForUriUniLinks() async {
  logCat('IN initPlatformState For Uri UniLinks');
  // Attach a listener to the Uri links stream
  _streamSubscription = appLinks.uriLinkStream.listen((Uri? uri) {
    // if (!mounted) return;
    // setState(() { });
    _latestUri = uri;
    latestLink = uri?.toString() ?? 'Unknown';
  }, onError: (Object err) {
    //if (!mounted) return;
    // setState(() {});
    _latestUri = null;
    latestLink = 'Failed to get latest link: $err.';
  });
  try {
    _initialUri = await appLinks.getInitialLink();
    logCat('initial uri: ${_initialUri?.path} | ${_initialUri?.queryParametersAll}');
    _initialLink = _initialUri?.toString();
  } on PlatformException {
    _initialUri = null;
    _initialLink = 'Failed to get initial uri.';
  } on FormatException {
    _initialUri = null;
    _initialLink = 'Bad parse the initial link as Uri.';
  }

  // 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;

  //setState(() { });
  _latestUri = _initialUri;
  latestLink = _initialLink!;
  //if (_isLoadDeepLink) {
  //getNavigatorPushNamed();
  //}
}