methodName property

String? get methodName

Retrieves the method name from the stack trace, if available.

Returns the method name as a string, or null if the method name cannot be determined.

Implementation

String? get methodName {
  final String methodInfo = _trace.toString().split('\n')[0];
  final List<String> classAndMethod = methodInfo.split('.');
  return classAndMethod.length > 1
      ? classAndMethod[1].startsWith('<')
          ? classAndMethod[0]
              .replaceAll('#0', '')
              .replaceAll(' ', '')
              .substring(
                  0,
                  (classAndMethod[0].indexOf('(') - 1) <= 0
                      ? 0
                      : classAndMethod[0].indexOf('(') - 1)
          : classAndMethod[1]
              .replaceAll('#0', '')
              .replaceAll(' ', '')
              .substring(
                  0,
                  (classAndMethod[1].indexOf('(') - 1) <= 0
                      ? 0
                      : classAndMethod[1].indexOf('(') - 1)
      : null;
}