Skip to content

Commit ff89d92

Browse files
[cross_file] Fix accidental constructor change (#3131)
* [cross_file] Fix accidental constructor change In #3095 I accidentally changed a constructor argument's nullability because of a misleading analyzer warning. That version has been retracted; this restores the original behavior. * Add a test * Better implementation
1 parent 89b2fec commit ff89d92

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

packages/cross_file/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
## 0.3.3+4
2+
3+
* Reverts an accidental change in a constructor argument's nullability.
4+
15
## 0.3.3+3
26

7+
* **RETRACTED**
38
* Updates code to fix strict-cast violations.
49
* Updates minimum SDK version to Flutter 3.0.
510

packages/cross_file/lib/src/types/interface.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class XFile extends XFileBase {
2222
/// `path` of the file doesn't match what the user sees when selecting it
2323
/// (like in web)
2424
XFile(
25-
super.path, {
25+
String super.path, {
2626
String? mimeType,
2727
String? name,
2828
int? length,

packages/cross_file/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: cross_file
22
description: An abstraction to allow working with files across multiple platforms.
33
repository: https://github.com/flutter/packages/tree/main/packages/cross_file
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+cross_file%22
5-
version: 0.3.3+3
5+
version: 0.3.3+4
66

77
environment:
88
sdk: ">=2.17.0 <3.0.0"

packages/cross_file/test/x_file_io_test.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ void main() {
7070

7171
await tempDir.delete(recursive: true);
7272
});
73+
74+
test('nullability is correct', () async {
75+
expect(_ensureNonnullPathArgument('a/path'), isNotNull);
76+
});
7377
});
7478

7579
group('Create with data', () {
@@ -107,6 +111,13 @@ void main() {
107111
});
108112
}
109113

114+
// This is to create an analysis error if the version of XFile in
115+
// interface.dart, which should never actually be used but is what the analyzer
116+
// runs against, has the nullability of `path` changed.
117+
XFile _ensureNonnullPathArgument(String? path) {
118+
return XFile(path!);
119+
}
120+
110121
/// An XFile subclass that tracks reads, for testing purposes.
111122
class TestXFile extends XFile {
112123
TestXFile(super.path);

0 commit comments

Comments
 (0)