validateVideoId static method

bool validateVideoId(
  1. String videoId
)

Returns true if the given videoId is valid.

Implementation

static bool validateVideoId(String videoId) {
  if (videoId.isNullOrWhiteSpace) {
    return false;
  }

  if (videoId.length != 11) {
    return false;
  }

  return !RegExp(r'[^0-9a-zA-Z_\-]').hasMatch(videoId);
}