DecoratorRule.url constructor
DecoratorRule.url({})
Implementation
factory DecoratorRule.url({
required TextStyle style,
required Function(String) onTap,
bool looseUrl = true,
bool humanize = false,
bool removeWww = false,
}) {
return DecoratorRule(
style: style,
regExp: CommonRegExp.url(
looseUrl: looseUrl,
),
onTap: (match) {
String url = match;
if (!match.startsWith("http://") && !match.startsWith("https://")) {
url = "https://$url";
}
if (url.endsWith(".")) {
url = url.substring(0, url.length - 1);
}
onTap(url);
},
transformMatch: (match) {
if (humanize) {
String url = match;
url = url.replaceFirst(RegExp('https?://'), '');
if (url.endsWith("/")) {
url = url.substring(0, url.length - 1);
}
if (removeWww) {
url = url.replaceFirst(RegExp(r'www\.'), '');
}
return url;
}
return match;
});
}