className property
String?
get
className
Retrieves the class name from the stack trace, if available.
Returns the class name as a string, or null
if the class name cannot be determined.
Implementation
String? get className {
List<String> lines = _trace.toString().split('\n');
List<String> finds = [];
for (String methodInfo in lines) {
List<String> classAndMethod = methodInfo.split('.');
if (classAndMethod.length > 1 && !classAndMethod[1].startsWith('<')) {
finds.add(classAndMethod[0].replaceAll('#0', '').replaceAll(' ', ''));
}
}
String? s = finds.length >= 3 ? finds[2] : null;
if (s != null) {
if (s.contains("(")) {
s = s.substring(0, s.indexOf("("));
}
if (s.startsWith("#")) {
s = s.substring(2);
}
}
return s;
}