formatStackTrace method
Implementation
String? formatStackTrace(StackTrace? stackTrace, int methodCount) {
List<String> lines = stackTrace
.toString()
.split('\n')
.where(
(line) =>
!_discardDeviceStacktraceLine(line) &&
!_discardWebStacktraceLine(line) &&
!_discardBrowserStacktraceLine(line) &&
line.isNotEmpty,
)
.toList();
List<String> formatted = [];
for (int count = 0; count < min(lines.length, methodCount); count++) {
var line = lines[count];
if (count < stackTraceBeginIndex) {
continue;
}
formatted.add('#$count ${line.replaceFirst(RegExp(r'#\d+\s+'), '')}');
}
if (formatted.isEmpty) {
return null;
} else {
return formatted.join('\n');
}
}