source_span 1.5.2

source_span is a library for tracking locations in source code. It's designed
to provide a standard representation for source code locations and spans so that
disparate packages can easily pass them among one another, and to make it easy
to generate human-friendly messages associated with a given piece of code.

The most commonly-used class is the package's namesake, SourceSpan. It
represents a span of characters in some source file, and is often attached to an
object that has been parsed to indicate where it was parsed from. It provides
access to the text of the span via SourceSpan.text and can be used to produce
human-friendly messages using SourceSpan.message().

When parsing code from a file, SourceFile is useful. Not only does it provide
an efficient means of computing line and column numbers, SourceFile.span()
returns special FileSpans that are able to provide more context for their
error messages.

The new SourceFile() constructor is deprecated. This constructed a source
file from a string's runes, rather than its code units, which runs counter to
the way Dart handles strings otherwise. The new StringFile.fromString()
constructor (see below) should be used instead.

The new SourceFile.fromString() constructor was added. This works like new
SourceFile(), except it uses code units rather than runes.

The current behavior when characters larger than 0xFFFF are passed to new
SourceFile.decoded() is now considered deprecated.

This package was extracted from the
source_maps package, but the
API has many differences. Among them:

Span has been renamed to SourceSpan and Location has been renamed to
SourceLocation to clarify their purpose and maintain consistency with the
package name. Likewise, SpanException is now SourceSpanException and
SpanFormatException is not SourceSpanFormatException.

FixedSpan and FixedLocation have been rolled into the Span and
Location classes, respectively.

SourceFile is more aggressive about validating its arguments. Out-of-bounds
lines, columns, and offsets will now throw errors rather than be silently
clamped.

SourceSpan.sourceUrl, SourceLocation.sourceUrl, and SourceFile.url now
return Uri objects rather than Strings. The constructors allow either
Strings or Uris.

Span.getLocationMessage and SourceFile.getLocationMessage are now
SourceSpan.message and SourceFile.message, respectively. Rather than
taking both a useColor and a color parameter, they now take a single
color parameter that controls both whether and which color is used.

Span.isIdentifier has been removed. This property doesn't make sense outside
of a source map context.

SourceFileSegment has been removed. This class wasn't widely used and was
inconsistent in its choice of which parameters were considered relative and
which absolute.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
source_span: ^1.5.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get.
Check the docs for your editor to learn more.