SentryFile class

The Sentry wrapper for the File IO implementation that creates a span out of the active transaction in the scope and a breadcrumb, which gets added to the hub. The span is started before the operation is executed and finished after. The File tracing isn't available for Web.

Example:

import 'dart:io';

final file = File('test.txt');
final sentryFile = SentryFile(file);
// span starts
await sentryFile.writeAsString('Hello World');
// span finishes, adds breadcrumb

All the copy, create, delete, open, rename, read, and write operations are supported.

Implemented types
Available Extensions

Constructors

SentryFile(File _file, {@internal Hub? hub})

Properties

absolute File
A File with the absolute path of path.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
isAbsolute bool
Whether this object's path is absolute.
no setteroverride
parent Directory
The parent directory of this entity.
no setteroverride
path String
Get the path of the file.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
uri Uri
A Uri representing the file system entity's location.
no setteroverride

Methods

copy(String newPath) Future<File>
Copies this file.
override
copySync(String newPath) File
Synchronously copies this file.
override
create({bool recursive = false, bool exclusive = false}) Future<File>
Creates the file.
override
createSync({bool recursive = false, bool exclusive = false}) → void
Synchronously creates the file.
override
delete({bool recursive = false}) Future<FileSystemEntity>
Deletes this File.
override
deleteSync({bool recursive = false}) → void
Synchronously deletes this File.
override
exists() Future<bool>
Checks whether the file system entity with this path exists.
override
existsSync() bool
Synchronously checks whether the file system entity with this path exists.
override
lastAccessed() Future<DateTime>
The last-accessed time of the file.
override
lastAccessedSync() DateTime
The last-accessed time of the file.
override
lastModified() Future<DateTime>
Get the last-modified time of the file.
override
lastModifiedSync() DateTime
Get the last-modified time of the file.
override
length() Future<int>
The length of the file.
override
lengthSync() int
The length of the file provided synchronously.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
open({FileMode mode = FileMode.read}) Future<RandomAccessFile>
Opens the file for random access operations.
override
openRead([int? start, int? end]) Stream<List<int>>
Creates a new independent Stream for the contents of this file.
override
openSync({FileMode mode = FileMode.read}) RandomAccessFile
Synchronously opens the file for random access operations.
override
openWrite({FileMode mode = FileMode.write, Encoding encoding = utf8}) IOSink
Creates a new independent IOSink for the file.
override
readAsBytes() Future<Uint8List>
Reads the entire file contents as a list of bytes.
override
readAsBytesSync() Uint8List
Synchronously reads the entire file contents as a list of bytes.
override
readAsLines({Encoding encoding = utf8}) Future<List<String>>
Reads the entire file contents as lines of text using the given Encoding.
override
readAsLinesSync({Encoding encoding = utf8}) List<String>
Synchronously reads the entire file contents as lines of text using the given Encoding.
override
readAsString({Encoding encoding = utf8}) Future<String>
Reads the entire file contents as a string using the given Encoding.
override
readAsStringSync({Encoding encoding = utf8}) String
Synchronously reads the entire file contents as a string using the given Encoding.
override
rename(String newPath) Future<File>
Renames this file.
override
renameSync(String newPath) File
Synchronously renames this file.
override
Resolves the path of a file system object relative to the current working directory.
override
resolveSymbolicLinksSync() String
Resolves the path of a file system object relative to the current working directory.
override
setLastAccessed(DateTime time) Future
Modifies the time the file was last accessed.
override
setLastAccessedSync(DateTime time) → void
Synchronously modifies the time the file was last accessed.
override
setLastModified(DateTime time) Future
Modifies the time the file was last modified.
override
setLastModifiedSync(DateTime time) → void
Synchronously modifies the time the file was last modified.
override
stat() Future<FileStat>
Calls the operating system's stat() function on path.
override
statSync() FileStat
Synchronously calls the operating system's stat() function on path.
override
toString() String
A string representation of this object.
inherited
watch({int events = FileSystemEvent.all, bool recursive = false}) Stream<FileSystemEvent>
Start watching the FileSystemEntity for changes.
override
writeAsBytes(List<int> bytes, {FileMode mode = FileMode.write, bool flush = false}) Future<File>
Writes a list of bytes to a file.
override
writeAsBytesSync(List<int> bytes, {FileMode mode = FileMode.write, bool flush = false}) → void
Synchronously writes a list of bytes to a file.
override
writeAsString(String contents, {FileMode mode = FileMode.write, Encoding encoding = utf8, bool flush = false}) Future<File>
Writes a string to a file.
override
writeAsStringSync(String contents, {FileMode mode = FileMode.write, Encoding encoding = utf8, bool flush = false}) → void
Synchronously writes a string to a file.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited