filePath property
String
get
filePath
Retrieves the file path from the current stack trace.
This method extracts the first file path found in the stack trace using platform-specific regular expressions.
Throws:
- FileNotFoundException if no file path is found in the stack trace.
Returns: A string representing the extracted file path.
Implementation
String get filePath {
final match = _extractFileMatch();
if (match == null) {
throw FileNotFoundException(
message: 'File not found in stack trace',
stackTrace: StackTrace.current,
);
}
return isWindows
? Uri.file(match.group(1)!, windows: true).toFilePath(windows: true)
: Uri.parse('file:///${match.group(1)!}').toFilePath();
}