source_span
Provides a standard representation for source code locations and spans.
1.10.2
12M downloads/mo
#10 most downloaded on pub.dev
dart-lang/tools
What this package is like to depend on
Last release 6 months ago
05 Feb 2026
Release timing varies
gaps range from 2 weeks to 1.7 years
Nearly every release is documented
notes for 35 of 35 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
40 releases · first in 2014
1 release in the last 12 months
see the full history below
Release timeline
40 releases · Jul 2014 to Feb 2026Releases
latest 40-
1.10.205 Feb 2026 -
1.10.111 Dec 2024 -
1.10.005 Apr 2023Release notes
Open source →- Add a
SourceFile.codeUnitsproperty. - Require Dart 2.18
- Add an API usage example in
example/.
- Add a
-
1.9.121 Jul 2022Release notes
Open source →-
Properly handle multi-line labels for multi-span highlights.
-
Populate the pubspec
repositoryfield.
-
-
1.9.012 Apr 2022Release notes
Open source →- Add
SourceSpanWithContextExtension.subspanthat returns aSourceSpanWithContextrather than a plainSourceSpan.
- Add
-
1.8.213 Jan 2022Release notes
Open source →- Fix a bug where highlighting multiple spans with
nullURLs could cause an assertion error. Now when multiple spans are passed withnullURLs, they're highlighted as though they all come from different source files.
- Fix a bug where highlighting multiple spans with
-
1.8.105 Feb 2021Release notes
Open source →- Fix a bug where the URL header for the highlights with multiple files would get omitted only one span has a non-null URI.
-
1.8.002 Feb 2021 -
1.8.0-nullsafety.405 Nov 2020 pre-releaseNothing published for this version
-
1.8.0-nullsafety.323 Oct 2020 pre-releaseNothing published for this version
-
1.8.0-nullsafety.221 Sep 2020 pre-releaseNothing published for this version
-
1.8.0-nullsafety.118 Sep 2020 pre-releaseNothing published for this version
-
1.8.0-nullsafety29 Jul 2020 pre-releaseNothing published for this version
-
1.7.018 Mar 2020Release notes
Open source →- Add a
SourceSpan.subspan()extension method which returns a slice of an existing source span.
- Add a
-
1.6.015 Jan 2020Release notes
Open source →- Add support for highlighting multiple source spans at once, providing more
context for span-based messages. This is exposed through the new APIs
SourceSpan.highlightMultiple()andSourceSpan.messageMultiple()(both extension methods),MultiSourceSpanException, andMultiSourceSpanFormatException.
- Add support for highlighting multiple source spans at once, providing more
context for span-based messages. This is exposed through the new APIs
-
1.5.528 Feb 2019Release notes
Open source →- Fix a bug where
FileSpan.highlight()would crash for spans that covered a trailing newline and a single additional empty line.
- Fix a bug where
-
1.5.429 Jan 2019Release notes
Open source →FileSpan.highlight()now properly highlights point spans at the beginning of lines.
-
1.5.324 Jan 2019Release notes
Open source →- Fix an edge case where
FileSpan.highlight()would put the highlight indicator in the wrong position when highlighting a point span after the end of a file.
- Fix an edge case where
-
1.5.217 Jan 2019Release notes
Open source →-
SourceFile.span()now goes to the end of the file by default, rather than ending one character before the end of the file. This matches the documented behavior. -
FileSpan.contextnow includes the full line on which the span appears for empty spans at the beginning and end of lines. -
Fix an edge case where
FileSpan.highlight()could crash when highlighting a span that ended with an empty line.
-
-
1.5.114 Jan 2019Release notes
Open source →-
Produce better source span highlights for multi-line spans that cover the entire last line of the span, including the newline.
-
Produce better source span highlights for spans that contain Windows-style newlines.
-
-
1.5.010 Jan 2019Release notes
Open source →-
Improve the output of
SourceSpan.highlight()andSourceSpan.message():- They now include line numbers.
- They will now print every line of a multiline span.
- They will now use Unicode box-drawing characters by default (this can be
controlled using
term_glyph.ascii).
-
-
1.4.118 Jul 2018 -
1.4.017 May 2017Release notes
Open source →-
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. Thenew StringFile.fromString()constructor (see below) should be used instead. -
The
new SourceFile.fromString()constructor was added. This works likenew SourceFile(), except it uses code units rather than runes. -
The current behavior when characters larger than
0xFFFFare passed tonew SourceFile.decoded()is now considered deprecated.
-
-
1.3.107 Jan 2017Release notes
Open source →- Properly highlight spans for lines that include tabs with
SourceSpan.highlight()andSourceSpan.message().
- Properly highlight spans for lines that include tabs with
-
1.3.008 Nov 2016Release notes
Open source →- Add
SourceSpan.highlight(), which returns just the highlighted text that would be included inSourceSpan.message().
- Add
-
1.2.421 Oct 2016 -
1.2.309 Jun 2016Release notes
Open source →- Fix a bug where a point span at the end of a file without a trailing newline would be printed incorrectly.
-
1.2.202 Mar 2016Release notes
Open source →- Allow
SourceSpanException.message,SourceSpanFormatException.source, andSourceSpanWithContext.contextto be overridden in strong mode.
- Allow
-
1.2.130 Sep 2015Release notes
Open source →- Fix the declared type of
FileSpan.startandFileSpan.end. In 1.2.0 these were mistakenly changed fromFileLocationtoSourceLocation.
- Fix the declared type of
-
1.2.002 Sep 2015Release notes
Open source →-
Deprecated: Extending
SourceLocationdirectly is deprecated. Instead, extend the newSourceLocationBaseclass or mix in the newSourceLocationMixinmixin. -
Dramatically improve the performance of
FileLocation.
-
-
1.1.602 Sep 2015 -
1.1.501 Sep 2015Release notes
Open source →- Fixed another case in which
FileSpan.unioncould throw an exception for external implementations ofFileSpan.
- Fixed another case in which
-
1.1.428 Aug 2015 -
1.1.318 Aug 2015Release notes
Open source →-
FileSpan.compareTo,FileSpan.==,FileSpan.union, andFileSpan.expandno longer throw exceptions for external implementations ofFileSpan. -
FileSpan.hashCodenow fully agrees withFileSpan.==.
-
-
1.1.231 Mar 2015Release notes
Open source →- Fixed validation in
SourceSpanWithContextto allow multiple occurrences oftextwithincontext.
- Fixed validation in
-
1.1.127 Mar 2015Release notes
Open source →- Fixed
FileSpan's context to include the full span text, not just the first line of it.
- Fixed
-
1.1.026 Mar 2015Release notes
Open source →- Added
SourceSpanWithContext: a span that also includes the full line of text that contains the span.
- Added
-
1.0.327 Jan 2015Release notes
Open source →- Cleanup equality operator to accept any Object rather than just a
SourceLocation.
- Cleanup equality operator to accept any Object rather than just a
-
1.0.221 Nov 2014Release notes
Open source →-
Avoid unintentionally allocating extra objects for internal
FileSpanoperations. -
Ensure that
SourceSpan.operator==works on arbitraryObjects.
-
-
1.0.024 Jul 2014Release notes
Open source →This package was extracted from the
source_mapspackage, but the API has many differences. Among them:-
Spanhas been renamed toSourceSpanandLocationhas been renamed toSourceLocationto clarify their purpose and maintain consistency with the package name. Likewise,SpanExceptionis nowSourceSpanExceptionandSpanFormatExceptionis notSourceSpanFormatException. -
FixedSpanandFixedLocationhave been rolled into theSpanandLocationclasses, respectively. -
SourceFileis 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, andSourceFile.urlnow returnUriobjects rather thanStrings. The constructors allow eitherStrings orUris. -
Span.getLocationMessageandSourceFile.getLocationMessageare nowSourceSpan.messageandSourceFile.message, respectively. Rather than taking both auseColorand acolorparameter, they now take a singlecolorparameter that controls both whether and which color is used. -
Span.isIdentifierhas been removed. This property doesn't make sense outside of a source map context. -
SourceFileSegmenthas been removed. This class wasn't widely used and was inconsistent in its choice of which parameters were considered relative and which absolute.
-