Skip to content

[cross_file] Fix accidental constructor change - #3131

Merged
auto-submit[bot] merged 3 commits into
flutter:mainfrom
stuartmorgan-g:cross-file-nullability-fix
Feb 1, 2023
Merged

[cross_file] Fix accidental constructor change#3131
auto-submit[bot] merged 3 commits into
flutter:mainfrom
stuartmorgan-g:cross-file-nullability-fix

Conversation

@stuartmorgan-g

@stuartmorgan-gstuartmorgan-g commented Jan 31, 2023

Copy link
Copy Markdown
Collaborator

In #3095 I accidentally changed a constructor argument's nullability because I wasn't familiar with the correct variation of super parameters, and addressed a lint warning incorrectly. That version has been retracted; this restores the original behavior.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

In flutter#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.
@stuartmorgan-g

Copy link
Copy Markdown
CollaboratorAuthor

The test is convoluted, but it works (and is arguably no more convoluted than the three-files-that-must-match structure of the class itself).

@stuartmorgan-g

Copy link
Copy Markdown
CollaboratorAuthor

Filed dart-lang/sdk#51196 for the false positive.

Although it's not actually clear to me why XFileBase has a constructor at all. Do you know what the reason was?

@asashour

asashour commented Feb 1, 2023

Copy link
Copy Markdown
Contributor

A humble suggestion, the code could be written as:

XFile(
Stringsuper.path, {
String? mimeType,
...
}) {

@stuartmorgan-g

Copy link
Copy Markdown
CollaboratorAuthor

A humble suggestion, the code could be written as

Indeed; fixed, and updated the PR description to reflect that the analyzer wasn't at all the problem. Thanks!

@ditmanditman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the test!!

@ditman

Copy link
Copy Markdown
Member

it's not actually clear to me why XFileBase has a constructor at all. Do you know what the reason was?

@stuartmorgan I don't remember, my only suspicion is to attempt to mandate that all subclasses (at least) have a path parameter? Not sure that's a valid solution (or requirement!)

@stuartmorgan-gstuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 1, 2023
@auto-submit
auto-submitBot merged commit ff89d92 into flutter:mainFeb 1, 2023
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
* [cross_file] Fix accidental constructor change
In flutter#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
bisor0627 pushed a commit to bisor0627/packages that referenced this pull request Jun 19, 2026
* [cross_file] Fix accidental constructor change
In flutter#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
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmitMerge PR when tree becomes green via auto submit Appp: cross_file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@stuartmorgan-g@asashour@ditman