Skip to content

[path_provider] Document null vs UnsupportedError return semantics#11793

Open
theprantadutta wants to merge 2 commits into
flutter:mainfrom
theprantadutta:fix/path-provider-getdownloadsdirectory-docs
Open

[path_provider] Document null vs UnsupportedError return semantics#11793
theprantadutta wants to merge 2 commits into
flutter:mainfrom
theprantadutta:fix/path-provider-getdownloadsdirectory-docs

Conversation

@theprantadutta
Copy link
Copy Markdown

@theprantadutta theprantadutta commented May 27, 2026

Updates the dartdoc for getDownloadsDirectory in path_provider and the matching getDownloadsPath contract on PathProviderPlatform to explain both return-value cases:

  • null — the platform supports the concept of a downloads directory but no such directory is currently available (concrete example: Linux without xdg-user-dir installed, or where xdg-user-dir fails when called).
  • UnsupportedError — the current platform has no concept of a downloads directory at all.

Previously the dartdoc only mentioned the UnsupportedError case, which left users unsure when they might see a null result.

The wording matches the explanations already given by maintainers in the linked issue thread.

Fixes flutter/flutter#143238

Pre-Review Checklist

This is a documentation-only change to public dartdoc comments. No code behavior changes; no new tests are required per the auto-exempt rules for changes that only affect comments/documentation.

The dartdoc on getDownloadsDirectory previously only mentioned the
UnsupportedError case, but the function also returns null when a
platform supports the concept of a downloads directory but no such
directory is currently available (for example, Linux without
xdg-user-dir installed, or when xdg-user-dir fails when called).

Document both return-value semantics on the public API method in
path_provider, and mirror the implementation contract on
PathProviderPlatform.getDownloadsPath in path_provider_platform_interface.

Wording follows the explanations @stuartmorgan-g and @Hixie gave in the
issue thread (flutter/flutter#143238).

Fixes flutter/flutter#143238
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request documents the difference between a null return and an UnsupportedError for getDownloadsDirectory and getDownloadsPath across the path_provider and path_provider_platform_interface packages. The review feedback points out a formatting issue in the CHANGELOG.md of path_provider, where inserting a new bullet point accidentally changes the nesting hierarchy of an existing sub-bullet point.

Comment on lines +6 to +7
* Documents the difference between a `null` return and an `UnsupportedError`
from `getDownloadsDirectory`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Inserting this bullet point here accidentally changes the nesting of the subsequent bullet point. The sub-bullet * Applications built with older versions of Flutter... (on lines 8-9) was meant to be nested under * Updates README..., but now it is nested under this new bullet point.

To preserve the correct hierarchy, please move this new bullet point to the end of the ## NEXT section (after the nested bullet point) or place it before the * Updates README... bullet point.

@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

Thanks for the contribution!

In the future, please do not delete the checklist that is in the PR template; it is there for a reason. This PR is missing required elements described in the checklist, which need to be addressed before it moves forward with review.

I am marking the PR as a Draft. Please re-add and complete the checklist, updating the PR as appropriate, and when that’s complete please feel free to mark the PR as ready for review.

Also, in the future please do not ping people in PR descriptions; it's extremely disruptive because it not only pings them on the PR (which is not constructive), it pings them again when the PR lands, and when it's mirrored into forks.

If you had to change anything in the [flutter/tests] repo, list the PRs here.

This is part of a different repository's template, which suggests that you used AI to create this entire PR description. Please don't do that. We have a template.

@stuartmorgan-g stuartmorgan-g marked this pull request as draft May 27, 2026 15:27
- Fix CHANGELOG.md nesting so the existing 'Applications built with older
  versions...' sub-bullet stays correctly nested under the README
  bullet (gemini-code-assist bot finding).
- Bump path_provider 2.1.5 -> 2.1.6 and path_provider_platform_interface
  2.1.2 -> 2.1.3, replacing the NEXT heading with the new version per
  the flutter/packages CHANGELOG conventions for continuous releases.
@theprantadutta
Copy link
Copy Markdown
Author

Thanks for the careful review — all addressed:

  • PR template: restored with the checklist completed (also removed the stray [flutter/tests] line that was from a different repo's template).
  • @-mentions: removed from the description.
  • CHANGELOG nesting: fixed in 8491953 so the Applications built with older versions… sub-bullet is correctly nested under the README bullet again. The new docs entry is moved to the end of the section.
  • Version bumps: path_provider 2.1.5 → 2.1.6 and path_provider_platform_interface 2.1.2 → 2.1.3, with ## NEXT renamed to the new version per the continuous-release CHANGELOG conventions.

Marking ready for review.

@theprantadutta theprantadutta marked this pull request as ready for review May 27, 2026 17:24
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the documentation for getDownloadsDirectory in path_provider and getDownloadsPath in path_provider_platform_interface to clarify the behavior and implementation contracts for returning null versus throwing an UnsupportedError. It also bumps the package versions to 2.1.6 and 2.1.3 respectively, and updates their changelogs. There are no review comments, and I have no feedback to provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

path_provider getDownloadsDirectory documentation doesn't say when it might return null

2 participants