createLinkToLocation method
createLink for a router location (/product?id=42), such as
GoRouterState.of(context).uri.toString(). utm_* keys in its query
are left out: they say how this visitor arrived, not what the page is.
Implementation
Future<Uri> createLinkToLocation(
String location, {
String? title,
String? description,
String? imageUrl,
FFXLinkCampaign campaign = FFXLinkCampaign.empty,
String? name,
bool forceRedirect = false,
}) async {
final uri = Uri.tryParse(location);
if (uri == null || uri.hasScheme || uri.hasAuthority) {
throw clientValidationError(
'"$location" is not a router location.',
'Pass a location such as /product?id=42, without a scheme or host.',
);
}
return createLink(
path: uri.path.isEmpty ? '/' : uri.path,
parameters: {
for (final MapEntry(:key, :value) in uri.queryParameters.entries)
if (!isUtmKey(key)) key: value,
},
title: title,
description: description,
imageUrl: imageUrl,
campaign: campaign,
name: name,
forceRedirect: forceRedirect,
);
}