splitTextAtNearestDot method
Implementation
List<String> splitTextAtNearestDot(String text, {int? chunkSize = 10}) {
List<String> result = [];
var currentChunk = [];
var listChar = ['.', ',', ':', ';', '!', '?'];
var words = text.split(' ');
for (String word in words) {
currentChunk.add(word);
if (currentChunk.length >= chunkSize!) {
if (containEndWith(word, listChar)) {
result.add(currentChunk.join(' '));
currentChunk = [];
}
}
}
if (currentChunk.isNotEmpty) {
result.add(currentChunk.join(' '));
}
return result;
}