SourceFile class

A class representing a source file.

This doesn't necessarily have to correspond to a file on disk, just a chunk of text usually with a URL associated with it.

Constructors

SourceFile(String text, {Object? url})
This constructor is deprecated.
SourceFile.decoded(Iterable<int> decodedChars, {Object? url})
Creates a new source file from a list of decoded code units.
SourceFile.fromString(String text, {Object? url})
Creates a new source file from text.

Properties

codeUnits List<int>
The code units of the characters in the file.
no setter
hashCode int
The hash code for this object.
no setterinherited
length int
The length of the file in characters.
no setter
lines int
The number of lines in the file.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
url Uri?
The URL where the source file is located.
final

Methods

getColumn(int offset, {int? line}) int
Gets the 0-based column corresponding to offset.
getLine(int offset) int
Gets the 0-based line corresponding to offset.
getOffset(int line, [int? column]) int
Gets the offset for a line and column.
getText(int start, [int? end]) String
Returns the text of the file from start to end (exclusive).
location(int offset) FileLocation
Returns a location at offset.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
span(int start, [int? end]) FileSpan
Returns a span from start to end (exclusive).
toString() String
A string representation of this object.
inherited

Operators

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