getTextStyleForRange method
Gets Text Style for start,end
range.
return TextStyle() style if nothing found.
Implementation
MatchSearchResult getTextStyleForRange(int start, int end, {List<String>? ignoreCases, List<String>? includeOnlyCases}){
TextStyle? textStyle;
DetectedType detectedType = DetectedType.plain_text;
String text = "";
allMatches.keys.forEach((type) {
var index = allMatches[type]!.indexWhere((match) => match.start == start && match.end == end);
if(index != -1){
text = allMatches[type]![index].input.substring(start,end);
var isIgnored = false;
if(includeOnlyCases?.isNotEmpty ?? false){
isIgnored = (includeOnlyCases?.indexWhere((t)=>t == text.trim()) ?? -1) == -1;
}else{
isIgnored = (ignoreCases?.indexWhere((t)=>t == text.trim()) ?? -1) >= 0;
}
if(isIgnored){
textStyle = ignoredTextStyle;
detectedType = DetectedType.plain_text;
}else{
textStyle = detectionTextStyles[type];
detectedType = type;
}
return;
}
});
return MatchSearchResult(textStyle ?? defaultTextStyle ?? TextStyle(), detectedType,text);
}