getLineRange function
Given a file and a string, find the line number of the string in the file.
fileThe file that we're searching in.searchingTextThe text to search for.positionThe position in the file to start searching from. Return A LineRange object.
Implementation
LineRange getLineRange(String file, String searchingText, [int postition = 0]) {
final charAtStart = file.indexOf(searchingText, postition);
final fileUpToStart = file.substring(0, charAtStart);
final fileUpToEnd = file.substring(0, charAtStart + searchingText.length);
return LineRange(
fileUpToStart.split('\n').length - 1, fileUpToEnd.split('\n').length - 1);
}