getSpotifyUrl static method

String getSpotifyUrl(
  1. String text
)

Implementation

static String getSpotifyUrl(String text) {
  RegExp regExp = RegExp(
      r'(https:\/\/open.spotify.com\/track\/[a-zA-Z0-9]+)|(open.spotify.com\/track\/[a-zA-Z0-9]+)|(spotify.com\/track\/[a-zA-Z0-9]+)'
  );

  String? matches = regExp.stringMatch(text);
  if (matches == null) return ''; /// Always returns here while the track URL is in the content parameter

  final String spotifyUrl = matches;
  return spotifyUrl;
}