open method
What uri opens: a link on this app's host (resolved, its open
reported), an "Open in app" URL on the app's scheme, or neither.
Never throws. The same URL asked again while it resolves, or within
2 s after, answers the first result and reports nothing more.
Implementation
Future<FFXLinkOpen> open(Uri uri) {
if (_closed || !isConfigured) return Future.value(const FFXNotALink());
final scheme = this.scheme;
final schemeLocation = scheme == null
? null
: locationOfAppSchemeUri(uri, scheme);
if (schemeLocation != null) {
return Future.value(FFXSchemeOpened(schemeLocation));
}
final code = _codeOf(uri);
if (code == null) return Future.value(const FFXNotALink());
final key = uri.toString();
final pending = _opens[key];
if (pending != null) return pending;
final opening = _openLink(code);
_opens[key] = opening;
unawaited(
opening.then((_) {
if (_closed) return;
late final Timer timer;
timer = Timer(_replayWindow, () {
_replayTimers.remove(timer);
if (identical(_opens[key], opening)) _opens.remove(key);
});
_replayTimers.add(timer);
}),
);
return opening;
}