PackageTrack
Sign in Get early access

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 2026
2015 2017 2019 2021 2023 2025
Release Pre-release

Releases

latest 40
  1. 1.10.2 05 Feb 2026
    Release notes
    • Speedup of the SourceFile.fromString constructor.
    Open source →
  2. 1.10.1 11 Dec 2024
    Release notes
    • Require Dart 3.1
    • Move to dart-lang/tools monorepo.
    Open source →
  3. 1.10.0 05 Apr 2023
    Release notes
    • Add a SourceFile.codeUnits property.
    • Require Dart 2.18
    • Add an API usage example in example/.
    Open source →
  4. 1.9.1 21 Jul 2022
    Release notes
    • Properly handle multi-line labels for multi-span highlights.

    • Populate the pubspec repository field.

    Open source →
  5. 1.9.0 12 Apr 2022
    Release notes
    • Add SourceSpanWithContextExtension.subspan that returns a SourceSpanWithContext rather than a plain SourceSpan.
    Open source →
  6. 1.8.2 13 Jan 2022
    Release notes
    • Fix a bug where highlighting multiple spans with null URLs could cause an assertion error. Now when multiple spans are passed with null URLs, they're highlighted as though they all come from different source files.
    Open source →
  7. 1.8.1 05 Feb 2021
    Release notes
    • Fix a bug where the URL header for the highlights with multiple files would get omitted only one span has a non-null URI.
    Open source →
  8. 1.8.0 02 Feb 2021
    Release notes
    • Stable release for null safety.
    Open source →
  9. 1.8.0-nullsafety.4 05 Nov 2020 pre-release

    Nothing published for this version

  10. 1.8.0-nullsafety.3 23 Oct 2020 pre-release

    Nothing published for this version

  11. 1.8.0-nullsafety.2 21 Sep 2020 pre-release

    Nothing published for this version

  12. 1.8.0-nullsafety.1 18 Sep 2020 pre-release

    Nothing published for this version

  13. 1.8.0-nullsafety 29 Jul 2020 pre-release

    Nothing published for this version

  14. 1.7.0 18 Mar 2020
    Release notes
    • Add a SourceSpan.subspan() extension method which returns a slice of an existing source span.
    Open source →
  15. 1.6.0 15 Jan 2020
    Release notes
    • 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() and SourceSpan.messageMultiple() (both extension methods), MultiSourceSpanException, and MultiSourceSpanFormatException.
    Open source →
  16. 1.5.5 28 Feb 2019
    Release notes
    • Fix a bug where FileSpan.highlight() would crash for spans that covered a trailing newline and a single additional empty line.
    Open source →
  17. 1.5.4 29 Jan 2019
    Release notes
    • FileSpan.highlight() now properly highlights point spans at the beginning of lines.
    Open source →
  18. 1.5.3 24 Jan 2019
    Release notes
    • 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.
    Open source →
  19. 1.5.2 17 Jan 2019
    Release notes
    • 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.context now 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.

    Open source →
  20. 1.5.1 14 Jan 2019
    Release notes
    • 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.

    Open source →
  21. 1.5.0 10 Jan 2019
    Release notes
    • Improve the output of SourceSpan.highlight() and SourceSpan.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).
    Open source →
  22. 1.4.1 18 Jul 2018
    Release notes
    • Set max SDK version to <3.0.0, and adjust other dependencies.
    Open source →
  23. 1.4.0 17 May 2017
    Release notes
    • 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.

    Open source →
  24. 1.3.1 07 Jan 2017
    Release notes
    • Properly highlight spans for lines that include tabs with SourceSpan.highlight() and SourceSpan.message().
    Open source →
  25. 1.3.0 08 Nov 2016
    Release notes
    • Add SourceSpan.highlight(), which returns just the highlighted text that would be included in SourceSpan.message().
    Open source →
  26. 1.2.4 21 Oct 2016
    Release notes
    • Fix a new strong mode error.
    Open source →
  27. 1.2.3 09 Jun 2016
    Release notes
    • Fix a bug where a point span at the end of a file without a trailing newline would be printed incorrectly.
    Open source →
  28. 1.2.2 02 Mar 2016
    Release notes
    • Allow SourceSpanException.message, SourceSpanFormatException.source, and SourceSpanWithContext.context to be overridden in strong mode.
    Open source →
  29. 1.2.1 30 Sep 2015
    Release notes
    • Fix the declared type of FileSpan.start and FileSpan.end. In 1.2.0 these were mistakenly changed from FileLocation to SourceLocation.
    Open source →
  30. 1.2.0 02 Sep 2015
    Release notes
    • Deprecated: Extending SourceLocation directly is deprecated. Instead, extend the new SourceLocationBase class or mix in the new SourceLocationMixin mixin.

    • Dramatically improve the performance of FileLocation.

    Open source →
  31. 1.1.6 02 Sep 2015
    Release notes
    • Optimize getLine() in SourceFile when repeatedly called.
    Open source →
  32. 1.1.5 01 Sep 2015
    Release notes
    • Fixed another case in which FileSpan.union could throw an exception for external implementations of FileSpan.
    Open source →
  33. 1.1.4 28 Aug 2015
    Release notes
    • Eliminated dart2js warning about overriding ==, but not hashCode.
    Open source →
  34. 1.1.3 18 Aug 2015
    Release notes
    • FileSpan.compareTo, FileSpan.==, FileSpan.union, and FileSpan.expand no longer throw exceptions for external implementations of FileSpan.

    • FileSpan.hashCode now fully agrees with FileSpan.==.

    Open source →
  35. 1.1.2 31 Mar 2015
    Release notes
    • Fixed validation in SourceSpanWithContext to allow multiple occurrences of text within context.
    Open source →
  36. 1.1.1 27 Mar 2015
    Release notes
    • Fixed FileSpan's context to include the full span text, not just the first line of it.
    Open source →
  37. 1.1.0 26 Mar 2015
    Release notes
    • Added SourceSpanWithContext: a span that also includes the full line of text that contains the span.
    Open source →
  38. 1.0.3 27 Jan 2015
    Release notes
    • Cleanup equality operator to accept any Object rather than just a SourceLocation.
    Open source →
  39. 1.0.2 21 Nov 2014
    Release notes
    • Avoid unintentionally allocating extra objects for internal FileSpan operations.

    • Ensure that SourceSpan.operator== works on arbitrary Objects.

    Open source →
  40. 1.0.0 24 Jul 2014
    Release notes

    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.

    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive