startTextSearch method
void
startTextSearch(})
Start a new search.
pattern
is the text to search for. It can be a String or a RegExp.
If caseInsensitive
is true, the search will be case insensitive.
If goToFirstMatch
is true, the viewer will automatically go to the first match.
If searchImmediately
is true, the search will start immediately,
otherwise it will wait for a short delay not to make the process too heavy.
Implementation
void startTextSearch(
Pattern pattern, {
bool caseInsensitive = true,
bool goToFirstMatch = true,
bool searchImmediately = false,
}) {
_cancelTextSearch();
final searchSession = ++_searchSession;
void search() {
if (_isIdenticalPattern(_lastSearchPattern, pattern)) return;
_lastSearchPattern = pattern;
if (pattern.isEmpty) {
_resetTextSearch();
return;
}
_startTextSearchInternal(
pattern, searchSession, caseInsensitive, goToFirstMatch);
}
if (searchImmediately) {
search();
} else {
_searchTextTimer = Timer(const Duration(milliseconds: 500), search);
}
}