Skip to content

Commit 7bf1948

Browse files
authored
Merge pull request flutter#96 from dart-lang/loader-span-late
Avoid a late FileSpan field
2 parents 7d2e51d + 25628a5 commit 7bf1948

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/src/loader.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,20 @@ class Loader {
2727

2828
/// The span of the entire stream emitted so far.
2929
FileSpan get span => _span;
30-
late FileSpan _span;
30+
FileSpan _span;
3131

3232
/// Creates a loader that loads [source].
3333
///
3434
/// [sourceUrl] can be a String or a [Uri].
35-
Loader(String source, {sourceUrl})
36-
: _parser = Parser(source, sourceUrl: sourceUrl) {
37-
var event = _parser.parse();
38-
_span = event.span;
35+
factory Loader(String source, {sourceUrl}) {
36+
var parser = Parser(source, sourceUrl: sourceUrl);
37+
var event = parser.parse();
3938
assert(event.type == EventType.streamStart);
39+
return Loader._(parser, event.span);
4040
}
4141

42+
Loader._(this._parser, this._span);
43+
4244
/// Loads the next document from the stream.
4345
///
4446
/// If there are no more documents, returns `null`.

0 commit comments

Comments
 (0)