Skip to content
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

[xdg_directories] Migrate to null safety #250

Closed
wants to merge 14 commits into from
Closed

[xdg_directories] Migrate to null safety #250

wants to merge 14 commits into from

Conversation

yash1200
Copy link
Contributor

@yash1200 yash1200 commented Nov 28, 2020

This PR migrates xdg_directories package to null safety (Waiting for mockito to be in nnbd, it'll be there by the end of december dart-lang/mockito#298 (comment)).

Fixes flutter/flutter#71506

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

I started to review this, but it seems like you have just made everything optional without looking at the code to see what can meaningfully be null and what can't. Please do a full pass over all of your changes and look at the semantics of the functions and this implementations to see what should actually be null, rather than just adding optionality everywhere.

packages/xdg_directories/lib/xdg_directories.dart Outdated Show resolved Hide resolved
packages/xdg_directories/lib/xdg_directories.dart Outdated Show resolved Hide resolved
packages/xdg_directories/lib/xdg_directories.dart Outdated Show resolved Hide resolved
packages/xdg_directories/pubspec.yaml Outdated Show resolved Hide resolved
packages/xdg_directories/test/xdg_directories_test.dart Outdated Show resolved Hide resolved
packages/xdg_directories/test/xdg_directories_test.dart Outdated Show resolved Hide resolved
packages/xdg_directories/test/xdg_directories_test.dart Outdated Show resolved Hide resolved
@bparrishMines
Copy link
Contributor

@yash1200 Are you still able to work on this?

@yash1200
Copy link
Contributor Author

@bparrishMines Yes I'm

@bparrishMines
Copy link
Contributor

@yash1200 It looks like you only have a couple comments from @stuartmorgan to address and fixing the formatting in xdg_directories/lib/xdg_directories.dart. Do you believe you could work on this within the next couple of days? Let me know if you would like any help.

@yash1200
Copy link
Contributor Author

@bparrishMines please take a look at the updates.

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

I'll do a full review later, but a quick comment on the naming discussion.

packages/xdg_directories/lib/xdg_directories.dart Outdated Show resolved Hide resolved

/// The base directory relative to which user-specific runtime
/// files and other file objects should be placed. (Corresponds to
/// `$XDG_RUNTIME_DIR`).
///
/// Throws [StateError] if the HOME environment variable is not set.
Directory get runtimeDir => _directoryFromEnvironment('XDG_RUNTIME_DIR', null);
Directory? get runtimeDir => _directoryFromEnvironment('XDG_RUNTIME_DIR');

/// Gets the xdg user directory named by `dirName`.
///
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on a bug that came in recently, we should make getUserDirectory return Directory?, because I think we'll want to add logic to make it catch run failures (e.g., due to xdg-user-dir not being installed) and return null, and changing the return type later would be a breaking change.

@@ -76,7 +74,7 @@ XDG_VIDEOS_DIR="$HOME/Videos"
expect(xdg.cacheHome.path, equals(testPath('.test_cache')));
expect(xdg.configHome.path, equals(testPath('.test_config')));
expect(xdg.dataHome.path, equals(testPath('.local/test_share')));
expect(xdg.runtimeDir.path, equals(testPath('.local/test_runtime')));
expect(xdg.runtimeDir!.path, equals(testPath('.local/test_runtime')));
Copy link
Contributor

Choose a reason for hiding this comment

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

This ! is not correct; the API can return a null. You need to validate both that it's not null, and that it matches if it's not.

@goderbauer goderbauer force-pushed the nnbd branch 2 times, most recently from 7df957a to 7a98c90 Compare January 27, 2021 01:57
@goderbauer goderbauer closed this Jan 27, 2021
@goderbauer goderbauer deleted the branch flutter:nnbd January 27, 2021 20:55
@stuartmorgan
Copy link
Contributor

@yash1200 Can you convert this to a pull request against master (or if that's not possible, open a new version of it against master, referencing this earlier PR)?

@yash1200
Copy link
Contributor Author

Yeah sure

@yash1200
Copy link
Contributor Author

The new PR is here #275

stuartmorgan pushed a commit to stuartmorgan/packages that referenced this pull request Apr 30, 2021
austinstoker pushed a commit to austinstoker/packages that referenced this pull request Apr 29, 2022
Advanced book example: Improve and migrate to null safety
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants