splitYoutubeId static method
splitYoutubeId Split youtube id from url youtube
Implementation
static String? splitYoutubeId(String url, {bool trimWhitespaces = true}) {
if (!url.contains(Constants.keyHttp) && (url.length == Constants.idLength))
return url;
if (trimWhitespaces) url = url.trim();
for (final regex in Constants.regexUrlYoutube) {
final Match? match = RegExp(regex).firstMatch(url);
if (match != null && match.groupCount >= 1) return match.group(1);
}
return null;
}