checkIsUrl function

bool checkIsUrl(
  1. String text
)

Implementation

bool checkIsUrl(String text) {
  final urlRegex = RegExp(
      r'https?:\/\/(www\\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&/=]*)',
      caseSensitive: false);
  final matchRet = urlRegex.allMatches(text);
  for (final match in matchRet) {
    final content = match.group(0);
    if (content != null) {
      // 存在匹配的字符串
      return true;
    }
  }
  return false;
}