toUrl method

String toUrl()

Implementation

String toUrl() {
  final pathname = link.query.isNotEmpty
      ? Uri.encodeComponent(link.toString().replaceFirst('/?', '?'))
      : link.toString().replaceFirst(RegExp(r'\/$'), '');

  final queryParameters = <String, dynamic>{
    if (label != null) 'label': label,
    if (message != null) 'message': message,
  };

  return Uri(
    scheme: solanaPayScheme,
    path: pathname,
    queryParameters: queryParameters.isNotEmpty
        ? Map<String, dynamic>.fromEntries(queryParameters.entries)
        : null,
  ).toString();
}