getYoutubeIdFromUrl property

String? get getYoutubeIdFromUrl

herhangi bir linkten youtube id sini cikartir. eger link yanlisssa null doner

Implementation

String? get getYoutubeIdFromUrl {
  var _regexps = [RegExp(r"^https:\/\/(?:www\.|m\.)?youtube\.com\/watch\?v=([_\-a-zA-Z0-9]{11}).*$"), RegExp(r"^https:\/\/(?:www\.|m\.)?youtube(?:-nocookie)?\.com\/embed\/([_\-a-zA-Z0-9]{11}).*$"), RegExp(r"^https:\/\/youtu\.be\/([_\-a-zA-Z0-9]{11}).*$")];

  if (safeLength < 3) return null;

  for (var exp in _regexps) {
    Match? match = exp.firstMatch(this!.trim());
    if (match != null && match.groupCount >= 1) return match.group(1);
  }
  return null;
}