exclusiveLineFiller method
This algorithm takes a line list and fills it with temp Lines so all list lines follow one set of rules
Implementation
Future<List<Line>> exclusiveLineFiller(List<Line> lineList,
List<Line> nameList, List<Line> maxList, int maxNameCount) async {
List<Line> result = [];
//this part checks and adds names.
for (int i = 0; i < lineList.length; i++) {
Line l = lineList[i];
if (i <= maxNameCount &&
maxList.isNotEmpty &&
l.cornerList![0].y > nameList.last.cornerList![1].y &&
l.cornerList![1].y < nameList.first.cornerList![0].y) {
if (l.text!.length > 1) {
result.add(l);
}
}
}
if (maxNameCount > result.length) {
int c = maxNameCount - result.length;
for (int i = 0; i < c; i++) {
result.add(Line(text: ""));
}
}
//this part checks and adds values.
for (int i = 0; i < maxList.length; i++) {
Line line = maxList[i];
List<Line> lines = [...lineList];
lines.removeWhere((element) =>
(element.cornerList![0].y <= line.cornerList![1].y) ||
(element.cornerList![1].y > line.cornerList![0].y) ||
(result.contains(element)));
result.add(lines.isEmpty
? Line(text: "", cornerList: line.cornerList)
: lines.first);
}
return result;
}