This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Migrate path_provider to null safety. #3460
Merged
bparrishMines
merged 7 commits into
flutter:master
from
bparrishMines:path_provider_nnbd
Feb 5, 2021
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
54dc150
start of migration
bparrishMines 08a9b61
add todo to puspec and use question mark in main
bparrishMines 65f7205
Merge branch 'master' of github.com:flutter/plugins into path_provide…
bparrishMines 458b9f2
use null safe linux impl
bparrishMines 169906b
hold off on converting example dir and update dependency
bparrishMines 0d9dd70
Merge branch 'master' of github.com:flutter/plugins into path_provide…
bparrishMines 3da050b
use safety not safe in changelog
bparrishMines File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| ## 2.0.0-nullsafety | ||
|
|
||
| * Migrate to null safe. | ||
|
|
||
| ## 1.6.28 | ||
|
|
||
| * Drop unused UUID dependency for tests. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/path_provider/path_provider/integration_test/path_provider_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,8 @@ PathProviderPlatform get _platform { | |
| // with a non-default instance. | ||
| if (!kIsWeb && PathProviderPlatform.instance is MethodChannelPathProvider) { | ||
| if (Platform.isLinux) { | ||
| PathProviderPlatform.instance = PathProviderLinux(); | ||
| // TODO: | ||
| //PathProviderPlatform.instance = PathProviderLinux(); | ||
|
||
| } else if (Platform.isWindows) { | ||
| PathProviderPlatform.instance = PathProviderWindows(); | ||
| } | ||
|
|
@@ -51,8 +52,8 @@ PathProviderPlatform get _platform { | |
| /// On iOS, this uses the `NSCachesDirectory` API. | ||
| /// | ||
| /// On Android, this uses the `getCacheDir` API on the context. | ||
| Future<Directory> getTemporaryDirectory() async { | ||
| final String path = await _platform.getTemporaryPath(); | ||
| Future<Directory?> getTemporaryDirectory() async { | ||
| final String? path = await _platform.getTemporaryPath(); | ||
| if (path == null) { | ||
| return null; | ||
| } | ||
|
|
@@ -69,8 +70,8 @@ Future<Directory> getTemporaryDirectory() async { | |
| /// If this directory does not exist, it is created automatically. | ||
| /// | ||
| /// On Android, this function uses the `getFilesDir` API on the context. | ||
| Future<Directory> getApplicationSupportDirectory() async { | ||
| final String path = await _platform.getApplicationSupportPath(); | ||
| Future<Directory?> getApplicationSupportDirectory() async { | ||
| final String? path = await _platform.getApplicationSupportPath(); | ||
| if (path == null) { | ||
| return null; | ||
| } | ||
|
|
@@ -83,8 +84,8 @@ Future<Directory> getApplicationSupportDirectory() async { | |
| /// | ||
| /// On Android, this function throws an [UnsupportedError] as no equivalent | ||
| /// path exists. | ||
| Future<Directory> getLibraryDirectory() async { | ||
| final String path = await _platform.getLibraryPath(); | ||
| Future<Directory?> getLibraryDirectory() async { | ||
| final String? path = await _platform.getLibraryPath(); | ||
| if (path == null) { | ||
| return null; | ||
| } | ||
|
|
@@ -100,8 +101,8 @@ Future<Directory> getLibraryDirectory() async { | |
| /// On Android, this uses the `getDataDirectory` API on the context. Consider | ||
| /// using [getExternalStorageDirectory] instead if data is intended to be visible | ||
| /// to the user. | ||
| Future<Directory> getApplicationDocumentsDirectory() async { | ||
| final String path = await _platform.getApplicationDocumentsPath(); | ||
| Future<Directory?> getApplicationDocumentsDirectory() async { | ||
| final String? path = await _platform.getApplicationDocumentsPath(); | ||
| if (path == null) { | ||
| return null; | ||
| } | ||
|
|
@@ -116,8 +117,8 @@ Future<Directory> getApplicationDocumentsDirectory() async { | |
| /// to access outside the app's sandbox. | ||
| /// | ||
| /// On Android this uses the `getExternalFilesDir(null)`. | ||
| Future<Directory> getExternalStorageDirectory() async { | ||
| final String path = await _platform.getExternalStoragePath(); | ||
| Future<Directory?> getExternalStorageDirectory() async { | ||
| final String? path = await _platform.getExternalStoragePath(); | ||
| if (path == null) { | ||
| return null; | ||
| } | ||
|
|
@@ -137,8 +138,11 @@ Future<Directory> getExternalStorageDirectory() async { | |
| /// | ||
| /// On Android this returns Context.getExternalCacheDirs() or | ||
| /// Context.getExternalCacheDir() on API levels below 19. | ||
| Future<List<Directory>> getExternalCacheDirectories() async { | ||
| final List<String> paths = await _platform.getExternalCachePaths(); | ||
| Future<List<Directory>?> getExternalCacheDirectories() async { | ||
| final List<String>? paths = await _platform.getExternalCachePaths(); | ||
| if (paths == null) { | ||
| return null; | ||
| } | ||
|
|
||
| return paths.map((String path) => Directory(path)).toList(); | ||
| } | ||
|
|
@@ -155,13 +159,16 @@ Future<List<Directory>> getExternalCacheDirectories() async { | |
| /// | ||
| /// On Android this returns Context.getExternalFilesDirs(String type) or | ||
| /// Context.getExternalFilesDir(String type) on API levels below 19. | ||
| Future<List<Directory>> getExternalStorageDirectories({ | ||
| Future<List<Directory>?> getExternalStorageDirectories({ | ||
| /// Optional parameter. See [StorageDirectory] for more informations on | ||
| /// how this type translates to Android storage directories. | ||
| StorageDirectory type, | ||
| StorageDirectory? type, | ||
| }) async { | ||
| final List<String> paths = | ||
| final List<String>? paths = | ||
| await _platform.getExternalStoragePaths(type: type); | ||
| if (paths == null) { | ||
| return null; | ||
| } | ||
|
|
||
| return paths.map((String path) => Directory(path)).toList(); | ||
| } | ||
|
|
@@ -171,8 +178,8 @@ Future<List<Directory>> getExternalStorageDirectories({ | |
| /// | ||
| /// On Android and on iOS, this function throws an [UnsupportedError] as no equivalent | ||
| /// path exists. | ||
| Future<Directory> getDownloadsDirectory() async { | ||
| final String path = await _platform.getDownloadsPath(); | ||
| Future<Directory?> getDownloadsDirectory() async { | ||
| final String? path = await _platform.getDownloadsPath(); | ||
| if (path == null) { | ||
| return null; | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.