isLink static method
Implementation
static bool isLink(String message) {
final linkRegExp = RegExp(
r'((https?:\/\/)?([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*)?)',
caseSensitive: false,
);
// Check if there's any match for the link
final matches = linkRegExp.allMatches(message);
if (matches.isEmpty) {
return false; // No link found
}
// Check if the message contains only a link
final onlyLink =
matches.length == 1 && matches.first.group(0) == message.trim();
return onlyLink
? true
: true; // Contains a link (either only or mixed with other text)
}