Skip to content

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
Collaborator

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

@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
Collaborator

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

Directory? get runtimeDir => _directoryFromEnvironment('XDG_RUNTIME_DIR');

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

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.

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
Collaborator

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-g
Copy link
Collaborator

@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-g pushed a commit to stuartmorgan-g/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