isUrl method

bool isUrl()

Checks if the string is a valid URL.

Implementation

bool isUrl() {
  final urlRegex =
      RegExp(r'^(https?:\/\/)?([\w\-]+(\.[\w\-]+)+)([\/\w\.\-]*)*\/?$');
  return urlRegex.hasMatch(this);
}