-
Notifications
You must be signed in to change notification settings - Fork 214
Refactor FileBasedAssetReader
and FileBasedAssetWriter
to ReaderWriter
.
#3876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PR HealthChangelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. |
5256e8f
to
8c772c4
Compare
8c772c4
to
49a653b
Compare
required super.assetPathProvider, | ||
required super.filesystem, | ||
required super.cache, | ||
required super.inputTracker, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You assume below this is non-null. Shouldn't you mark it as such?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and possibly overwrite the inputTracker getter to non-null to avoid some !
s below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's awkward because of the extends
relationship, the super class copyWith
wants it to be nullable. It could be covariant
.
Really the awkward part is the test and non-test code doing different things, making it nullable for one and not for the other.
Fortunately the next PR addresses exactly this, unifying test and non-test use and moving InputTracker
out of AssetReader
entirely to the one place it's actually used :)
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I understand... Why wouldn't this work:
diff --git a/build_test/lib/src/in_memory_reader_writer.dart b/build_test/lib/src/in_memory_reader_writer.dart
index f4ca7bdd..66e010f4 100644
--- a/build_test/lib/src/in_memory_reader_writer.dart
+++ b/build_test/lib/src/in_memory_reader_writer.dart
@@ -43,9 +43,12 @@ class InMemoryAssetReaderWriter extends ReaderWriter
required super.assetPathProvider,
required super.filesystem,
required super.cache,
- required super.inputTracker,
+ required InputTracker super.inputTracker,
}) : super.using();
+ @override
+ InputTracker get inputTracker => super.inputTracker!;
+
@override
InMemoryAssetReaderWriter copyWith({
AssetPathProvider? assetPathProvider,
I mean, with it going away it doesn't matter, but I don't understand the argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you are correct.
The problem I mentioned only happens if inputTracker
is a parameter to copyWith
, but it no longer is. Sorry for the confusion, I was repeating compiler complaints from a stale state :)
For #3811.
FileBasedAssetReader
andFileBasedAssetWriter
merge intoReaderWriter
, and can now be used for testing too when an in-memory filesystem is provided, replacing most ofInMemoryAssetReaderWriter
. Finding assets is split out to classesInMemoryAssetFinder
andPackageGraphAssetFinder
to allow it to work for both cases.