From 54dc15068603ef405a4f6bd13d0864a603b82570 Mon Sep 17 00:00:00 2001 From: Maurice Parrish Date: Fri, 22 Jan 2021 13:33:19 -0500 Subject: [PATCH 1/5] start of migration --- .../path_provider/path_provider/CHANGELOG.md | 4 ++ .../integration_test/path_provider_test.dart | 2 + .../path_provider/example/lib/main.dart | 38 +++++++-------- .../path_provider/example/pubspec.yaml | 4 +- .../example/test_driver/integration_test.dart | 2 + .../integration_test/path_provider_test.dart | 6 +++ .../path_provider/lib/path_provider.dart | 46 +++++++++++-------- .../path_provider/path_provider/pubspec.yaml | 17 ++++--- .../test/path_provider_test.dart | 38 +++++++-------- 9 files changed, 89 insertions(+), 68 deletions(-) diff --git a/packages/path_provider/path_provider/CHANGELOG.md b/packages/path_provider/path_provider/CHANGELOG.md index bd6c0bc651f5..31e6e7562faf 100644 --- a/packages/path_provider/path_provider/CHANGELOG.md +++ b/packages/path_provider/path_provider/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.0-nullsafety + +* Migrate to null safe. + ## 1.6.27 * Update the example app: remove the deprecated `RaisedButton` and `FlatButton` widgets. diff --git a/packages/path_provider/path_provider/example/integration_test/path_provider_test.dart b/packages/path_provider/path_provider/example/integration_test/path_provider_test.dart index 8eb8520b5b4b..2b12c82f959b 100644 --- a/packages/path_provider/path_provider/example/integration_test/path_provider_test.dart +++ b/packages/path_provider/path_provider/example/integration_test/path_provider_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=2.9 + import 'dart:async'; import 'dart:io'; diff --git a/packages/path_provider/path_provider/example/lib/main.dart b/packages/path_provider/path_provider/example/lib/main.dart index 8e929a6882fe..ddc1f8a6e2d5 100644 --- a/packages/path_provider/path_provider/example/lib/main.dart +++ b/packages/path_provider/path_provider/example/lib/main.dart @@ -28,7 +28,7 @@ class MyApp extends StatelessWidget { } class MyHomePage extends StatefulWidget { - MyHomePage({Key key, this.title}) : super(key: key); + MyHomePage({Key? key, required this.title}) : super(key: key); final String title; @override @@ -36,13 +36,13 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - Future _tempDirectory; - Future _appSupportDirectory; - Future _appLibraryDirectory; - Future _appDocumentsDirectory; - Future _externalDocumentsDirectory; - Future> _externalStorageDirectories; - Future> _externalCacheDirectories; + Future? _tempDirectory; + Future? _appSupportDirectory; + Future? _appLibraryDirectory; + Future? _appDocumentsDirectory; + Future? _externalDocumentsDirectory; + Future?>? _externalStorageDirectories; + Future?>? _externalCacheDirectories; void _requestTempDirectory() { setState(() { @@ -51,13 +51,13 @@ class _MyHomePageState extends State { } Widget _buildDirectory( - BuildContext context, AsyncSnapshot snapshot) { + BuildContext context, AsyncSnapshot snapshot) { Text text = const Text(''); if (snapshot.connectionState == ConnectionState.done) { if (snapshot.hasError) { text = Text('Error: ${snapshot.error}'); } else if (snapshot.hasData) { - text = Text('path: ${snapshot.data.path}'); + text = Text('path: ${snapshot.data!.path}'); } else { text = const Text('path unavailable'); } @@ -66,14 +66,14 @@ class _MyHomePageState extends State { } Widget _buildDirectories( - BuildContext context, AsyncSnapshot> snapshot) { + BuildContext context, AsyncSnapshot?> snapshot) { Text text = const Text(''); if (snapshot.connectionState == ConnectionState.done) { if (snapshot.hasError) { text = Text('Error: ${snapshot.error}'); } else if (snapshot.hasData) { final String combined = - snapshot.data.map((Directory d) => d.path).join(', '); + snapshot.data!.map((Directory d) => d.path).join(', '); text = Text('paths: $combined'); } else { text = const Text('path unavailable'); @@ -134,7 +134,7 @@ class _MyHomePageState extends State { onPressed: _requestTempDirectory, ), ), - FutureBuilder( + FutureBuilder( future: _tempDirectory, builder: _buildDirectory), Padding( padding: const EdgeInsets.all(16.0), @@ -143,7 +143,7 @@ class _MyHomePageState extends State { onPressed: _requestAppDocumentsDirectory, ), ), - FutureBuilder( + FutureBuilder( future: _appDocumentsDirectory, builder: _buildDirectory), Padding( padding: const EdgeInsets.all(16.0), @@ -152,7 +152,7 @@ class _MyHomePageState extends State { onPressed: _requestAppSupportDirectory, ), ), - FutureBuilder( + FutureBuilder( future: _appSupportDirectory, builder: _buildDirectory), Padding( padding: const EdgeInsets.all(16.0), @@ -161,7 +161,7 @@ class _MyHomePageState extends State { onPressed: _requestAppLibraryDirectory, ), ), - FutureBuilder( + FutureBuilder( future: _appLibraryDirectory, builder: _buildDirectory), Padding( padding: const EdgeInsets.all(16.0), @@ -172,7 +172,7 @@ class _MyHomePageState extends State { Platform.isIOS ? null : _requestExternalStorageDirectory, ), ), - FutureBuilder( + FutureBuilder( future: _externalDocumentsDirectory, builder: _buildDirectory), Column(children: [ Padding( @@ -190,7 +190,7 @@ class _MyHomePageState extends State { ), ), ]), - FutureBuilder>( + FutureBuilder?>( future: _externalStorageDirectories, builder: _buildDirectories), Column(children: [ @@ -204,7 +204,7 @@ class _MyHomePageState extends State { ), ), ]), - FutureBuilder>( + FutureBuilder?>( future: _externalCacheDirectories, builder: _buildDirectories), ], ), diff --git a/packages/path_provider/path_provider/example/pubspec.yaml b/packages/path_provider/path_provider/example/pubspec.yaml index 8659da753e15..c6cba57cd23b 100644 --- a/packages/path_provider/path_provider/example/pubspec.yaml +++ b/packages/path_provider/path_provider/example/pubspec.yaml @@ -12,11 +12,11 @@ dev_dependencies: path: ../../../integration_test flutter_driver: sdk: flutter - pedantic: ^1.8.0 + pedantic: ^1.10.0-nullsafety flutter: uses-material-design: true environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.12.0-0 <3.0.0" flutter: ">=1.12.13+hotfix.5 <2.0.0" diff --git a/packages/path_provider/path_provider/example/test_driver/integration_test.dart b/packages/path_provider/path_provider/example/test_driver/integration_test.dart index 7a2c21338786..ac106b63b339 100644 --- a/packages/path_provider/path_provider/example/test_driver/integration_test.dart +++ b/packages/path_provider/path_provider/example/test_driver/integration_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=2.9 + import 'dart:async'; import 'dart:convert'; import 'dart:io'; diff --git a/packages/path_provider/path_provider/integration_test/path_provider_test.dart b/packages/path_provider/path_provider/integration_test/path_provider_test.dart index 18570aeca57e..da368d52b832 100644 --- a/packages/path_provider/path_provider/integration_test/path_provider_test.dart +++ b/packages/path_provider/path_provider/integration_test/path_provider_test.dart @@ -1,3 +1,9 @@ +// Copyright 2019 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// @dart=2.9 + import 'package:flutter_test/flutter_test.dart'; import 'package:path_provider/path_provider.dart'; import 'package:integration_test/integration_test.dart'; diff --git a/packages/path_provider/path_provider/lib/path_provider.dart b/packages/path_provider/path_provider/lib/path_provider.dart index 0fbab57700be..197915bc66e6 100644 --- a/packages/path_provider/path_provider/lib/path_provider.dart +++ b/packages/path_provider/path_provider/lib/path_provider.dart @@ -6,7 +6,8 @@ import 'dart:async'; import 'dart:io' show Directory, Platform; import 'package:flutter/foundation.dart' show kIsWeb, visibleForTesting; -import 'package:path_provider_linux/path_provider_linux.dart'; +// TODO: +//import 'package:path_provider_linux/path_provider_linux.dart'; import 'package:path_provider_windows/path_provider_windows.dart'; import 'package:path_provider_platform_interface/path_provider_platform_interface.dart'; import 'package:path_provider_platform_interface/src/method_channel_path_provider.dart'; @@ -29,7 +30,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 +53,8 @@ PathProviderPlatform get _platform { /// On iOS, this uses the `NSCachesDirectory` API. /// /// On Android, this uses the `getCacheDir` API on the context. -Future getTemporaryDirectory() async { - final String path = await _platform.getTemporaryPath(); +Future getTemporaryDirectory() async { + final String? path = await _platform.getTemporaryPath(); if (path == null) { return null; } @@ -69,8 +71,8 @@ Future getTemporaryDirectory() async { /// If this directory does not exist, it is created automatically. /// /// On Android, this function uses the `getFilesDir` API on the context. -Future getApplicationSupportDirectory() async { - final String path = await _platform.getApplicationSupportPath(); +Future getApplicationSupportDirectory() async { + final String? path = await _platform.getApplicationSupportPath(); if (path == null) { return null; } @@ -83,8 +85,8 @@ Future getApplicationSupportDirectory() async { /// /// On Android, this function throws an [UnsupportedError] as no equivalent /// path exists. -Future getLibraryDirectory() async { - final String path = await _platform.getLibraryPath(); +Future getLibraryDirectory() async { + final String? path = await _platform.getLibraryPath(); if (path == null) { return null; } @@ -100,8 +102,8 @@ Future 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 getApplicationDocumentsDirectory() async { - final String path = await _platform.getApplicationDocumentsPath(); +Future getApplicationDocumentsDirectory() async { + final String? path = await _platform.getApplicationDocumentsPath(); if (path == null) { return null; } @@ -116,8 +118,8 @@ Future getApplicationDocumentsDirectory() async { /// to access outside the app's sandbox. /// /// On Android this uses the `getExternalFilesDir(null)`. -Future getExternalStorageDirectory() async { - final String path = await _platform.getExternalStoragePath(); +Future getExternalStorageDirectory() async { + final String? path = await _platform.getExternalStoragePath(); if (path == null) { return null; } @@ -137,8 +139,11 @@ Future getExternalStorageDirectory() async { /// /// On Android this returns Context.getExternalCacheDirs() or /// Context.getExternalCacheDir() on API levels below 19. -Future> getExternalCacheDirectories() async { - final List paths = await _platform.getExternalCachePaths(); +Future?> getExternalCacheDirectories() async { + final List? paths = await _platform.getExternalCachePaths(); + if (paths == null) { + return null; + } return paths.map((String path) => Directory(path)).toList(); } @@ -155,13 +160,16 @@ Future> getExternalCacheDirectories() async { /// /// On Android this returns Context.getExternalFilesDirs(String type) or /// Context.getExternalFilesDir(String type) on API levels below 19. -Future> getExternalStorageDirectories({ +Future?> getExternalStorageDirectories({ /// Optional parameter. See [StorageDirectory] for more informations on /// how this type translates to Android storage directories. - StorageDirectory type, + StorageDirectory? type, }) async { - final List paths = + final List? paths = await _platform.getExternalStoragePaths(type: type); + if (paths == null) { + return null; + } return paths.map((String path) => Directory(path)).toList(); } @@ -171,8 +179,8 @@ Future> getExternalStorageDirectories({ /// /// On Android and on iOS, this function throws an [UnsupportedError] as no equivalent /// path exists. -Future getDownloadsDirectory() async { - final String path = await _platform.getDownloadsPath(); +Future getDownloadsDirectory() async { + final String? path = await _platform.getDownloadsPath(); if (path == null) { return null; } diff --git a/packages/path_provider/path_provider/pubspec.yaml b/packages/path_provider/path_provider/pubspec.yaml index 649b3420d72f..b8b7e319ab8b 100644 --- a/packages/path_provider/path_provider/pubspec.yaml +++ b/packages/path_provider/path_provider/pubspec.yaml @@ -1,7 +1,7 @@ name: path_provider description: Flutter plugin for getting commonly used locations on host platform file systems, such as the temp and app data directories. homepage: https://github.com/flutter/plugins/tree/master/packages/path_provider/path_provider -version: 1.6.27 +version: 2.0.0-nullsafety flutter: plugin: @@ -21,10 +21,10 @@ flutter: dependencies: flutter: sdk: flutter - path_provider_platform_interface: ^1.0.1 + path_provider_platform_interface: ^2.0.0-nullsafety path_provider_macos: ^0.0.4 - path_provider_linux: ^0.0.1 - path_provider_windows: ^0.0.4 + #path_provider_linux: ^0.0.1 + path_provider_windows: ^0.1.0-nullsafety dev_dependencies: integration_test: @@ -33,11 +33,10 @@ dev_dependencies: sdk: flutter flutter_driver: sdk: flutter - uuid: "^1.0.0" - pedantic: ^1.8.0 - mockito: ^4.1.1 - plugin_platform_interface: ^1.0.0 + pedantic: ^1.10.0-nullsafety + mockito: ^5.0.0-nullsafety.0 + plugin_platform_interface: ^1.1.0-nullsafety environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.12.0-0 <3.0.0" flutter: ">=1.12.13+hotfix.5" diff --git a/packages/path_provider/path_provider/test/path_provider_test.dart b/packages/path_provider/path_provider/test/path_provider_test.dart index eb17178b9975..aec5e060f631 100644 --- a/packages/path_provider/path_provider/test/path_provider_test.dart +++ b/packages/path_provider/path_provider/test/path_provider_test.dart @@ -28,45 +28,45 @@ void main() { }); test('getTemporaryDirectory', () async { - Directory result = await getTemporaryDirectory(); - expect(result.path, kTemporaryPath); + Directory? result = await getTemporaryDirectory(); + expect(result?.path, kTemporaryPath); }); test('getApplicationSupportDirectory', () async { - Directory result = await getApplicationSupportDirectory(); - expect(result.path, kApplicationSupportPath); + Directory? result = await getApplicationSupportDirectory(); + expect(result?.path, kApplicationSupportPath); }); test('getLibraryDirectory', () async { - Directory result = await getLibraryDirectory(); - expect(result.path, kLibraryPath); + Directory? result = await getLibraryDirectory(); + expect(result?.path, kLibraryPath); }); test('getApplicationDocumentsDirectory', () async { - Directory result = await getApplicationDocumentsDirectory(); - expect(result.path, kApplicationDocumentsPath); + Directory? result = await getApplicationDocumentsDirectory(); + expect(result?.path, kApplicationDocumentsPath); }); test('getExternalStorageDirectory', () async { - Directory result = await getExternalStorageDirectory(); - expect(result.path, kExternalStoragePath); + Directory? result = await getExternalStorageDirectory(); + expect(result?.path, kExternalStoragePath); }); test('getExternalCacheDirectories', () async { - List result = await getExternalCacheDirectories(); - expect(result.length, 1); - expect(result.first.path, kExternalCachePath); + List? result = await getExternalCacheDirectories(); + expect(result?.length, 1); + expect(result?.first.path, kExternalCachePath); }); test('getExternalStorageDirectories', () async { - List result = await getExternalStorageDirectories(); - expect(result.length, 1); - expect(result.first.path, kExternalStoragePath); + List? result = await getExternalStorageDirectories(); + expect(result?.length, 1); + expect(result?.first.path, kExternalStoragePath); }); test('getDownloadsDirectory', () async { - Directory result = await getDownloadsDirectory(); - expect(result.path, kDownloadsPath); + Directory? result = await getDownloadsDirectory(); + expect(result?.path, kDownloadsPath); }); }); } @@ -99,7 +99,7 @@ class MockPathProviderPlatform extends Mock } Future> getExternalStoragePaths({ - StorageDirectory type, + StorageDirectory? type, }) async { return [kExternalStoragePath]; } From 08a9b6181765e238670de8849c8409c5e96b6fa4 Mon Sep 17 00:00:00 2001 From: Maurice Parrish Date: Fri, 22 Jan 2021 18:07:29 -0500 Subject: [PATCH 2/5] add todo to puspec and use question mark in main --- packages/path_provider/path_provider/example/lib/main.dart | 6 +++--- packages/path_provider/path_provider/pubspec.yaml | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/path_provider/path_provider/example/lib/main.dart b/packages/path_provider/path_provider/example/lib/main.dart index ddc1f8a6e2d5..15f3e4ab1ea1 100644 --- a/packages/path_provider/path_provider/example/lib/main.dart +++ b/packages/path_provider/path_provider/example/lib/main.dart @@ -57,7 +57,7 @@ class _MyHomePageState extends State { if (snapshot.hasError) { text = Text('Error: ${snapshot.error}'); } else if (snapshot.hasData) { - text = Text('path: ${snapshot.data!.path}'); + text = Text('path: ${snapshot.data?.path}'); } else { text = const Text('path unavailable'); } @@ -72,8 +72,8 @@ class _MyHomePageState extends State { if (snapshot.hasError) { text = Text('Error: ${snapshot.error}'); } else if (snapshot.hasData) { - final String combined = - snapshot.data!.map((Directory d) => d.path).join(', '); + final String? combined = + snapshot.data?.map((Directory d) => d.path).join(', '); text = Text('paths: $combined'); } else { text = const Text('path unavailable'); diff --git a/packages/path_provider/path_provider/pubspec.yaml b/packages/path_provider/path_provider/pubspec.yaml index b8b7e319ab8b..b8f5c0da1ebb 100644 --- a/packages/path_provider/path_provider/pubspec.yaml +++ b/packages/path_provider/path_provider/pubspec.yaml @@ -23,6 +23,7 @@ dependencies: sdk: flutter path_provider_platform_interface: ^2.0.0-nullsafety path_provider_macos: ^0.0.4 + # TODO : #path_provider_linux: ^0.0.1 path_provider_windows: ^0.1.0-nullsafety From 458b9f2a81c27fa933891b2414b9ddbab2f5d5f1 Mon Sep 17 00:00:00 2001 From: Maurice Parrish Date: Wed, 3 Feb 2021 15:47:35 -0800 Subject: [PATCH 3/5] use null safe linux impl --- packages/path_provider/path_provider/lib/path_provider.dart | 3 +-- packages/path_provider/path_provider/pubspec.yaml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/path_provider/path_provider/lib/path_provider.dart b/packages/path_provider/path_provider/lib/path_provider.dart index 197915bc66e6..ae1fa8038966 100644 --- a/packages/path_provider/path_provider/lib/path_provider.dart +++ b/packages/path_provider/path_provider/lib/path_provider.dart @@ -6,8 +6,7 @@ import 'dart:async'; import 'dart:io' show Directory, Platform; import 'package:flutter/foundation.dart' show kIsWeb, visibleForTesting; -// TODO: -//import 'package:path_provider_linux/path_provider_linux.dart'; +import 'package:path_provider_linux/path_provider_linux.dart'; import 'package:path_provider_windows/path_provider_windows.dart'; import 'package:path_provider_platform_interface/path_provider_platform_interface.dart'; import 'package:path_provider_platform_interface/src/method_channel_path_provider.dart'; diff --git a/packages/path_provider/path_provider/pubspec.yaml b/packages/path_provider/path_provider/pubspec.yaml index c1d2a8e385bb..28042b7c646a 100644 --- a/packages/path_provider/path_provider/pubspec.yaml +++ b/packages/path_provider/path_provider/pubspec.yaml @@ -23,8 +23,7 @@ dependencies: sdk: flutter path_provider_platform_interface: ^2.0.0-nullsafety path_provider_macos: ^0.0.4 -# TODO(bparrishMines): Add dependency once path_provider_linux is migrated to null safety. -# path_provider_linux: ^0.0.1 + path_provider_linux: ^0.2.0-nullsafety path_provider_windows: ^0.1.0-nullsafety dev_dependencies: From 169906b4c64bd0fb71e58e5ea169ba4ce453c651 Mon Sep 17 00:00:00 2001 From: Maurice Parrish Date: Wed, 3 Feb 2021 16:41:00 -0800 Subject: [PATCH 4/5] hold off on converting example dir and update dependency --- .../integration_test/path_provider_test.dart | 2 - .../path_provider/example/lib/main.dart | 40 +++++++++---------- .../path_provider/example/pubspec.yaml | 4 +- .../example/test_driver/integration_test.dart | 2 - .../path_provider/lib/path_provider.dart | 3 +- .../path_provider/path_provider/pubspec.yaml | 2 +- 6 files changed, 24 insertions(+), 29 deletions(-) diff --git a/packages/path_provider/path_provider/example/integration_test/path_provider_test.dart b/packages/path_provider/path_provider/example/integration_test/path_provider_test.dart index 2b12c82f959b..8eb8520b5b4b 100644 --- a/packages/path_provider/path_provider/example/integration_test/path_provider_test.dart +++ b/packages/path_provider/path_provider/example/integration_test/path_provider_test.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'dart:io'; diff --git a/packages/path_provider/path_provider/example/lib/main.dart b/packages/path_provider/path_provider/example/lib/main.dart index 15f3e4ab1ea1..8e929a6882fe 100644 --- a/packages/path_provider/path_provider/example/lib/main.dart +++ b/packages/path_provider/path_provider/example/lib/main.dart @@ -28,7 +28,7 @@ class MyApp extends StatelessWidget { } class MyHomePage extends StatefulWidget { - MyHomePage({Key? key, required this.title}) : super(key: key); + MyHomePage({Key key, this.title}) : super(key: key); final String title; @override @@ -36,13 +36,13 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - Future? _tempDirectory; - Future? _appSupportDirectory; - Future? _appLibraryDirectory; - Future? _appDocumentsDirectory; - Future? _externalDocumentsDirectory; - Future?>? _externalStorageDirectories; - Future?>? _externalCacheDirectories; + Future _tempDirectory; + Future _appSupportDirectory; + Future _appLibraryDirectory; + Future _appDocumentsDirectory; + Future _externalDocumentsDirectory; + Future> _externalStorageDirectories; + Future> _externalCacheDirectories; void _requestTempDirectory() { setState(() { @@ -51,13 +51,13 @@ class _MyHomePageState extends State { } Widget _buildDirectory( - BuildContext context, AsyncSnapshot snapshot) { + BuildContext context, AsyncSnapshot snapshot) { Text text = const Text(''); if (snapshot.connectionState == ConnectionState.done) { if (snapshot.hasError) { text = Text('Error: ${snapshot.error}'); } else if (snapshot.hasData) { - text = Text('path: ${snapshot.data?.path}'); + text = Text('path: ${snapshot.data.path}'); } else { text = const Text('path unavailable'); } @@ -66,14 +66,14 @@ class _MyHomePageState extends State { } Widget _buildDirectories( - BuildContext context, AsyncSnapshot?> snapshot) { + BuildContext context, AsyncSnapshot> snapshot) { Text text = const Text(''); if (snapshot.connectionState == ConnectionState.done) { if (snapshot.hasError) { text = Text('Error: ${snapshot.error}'); } else if (snapshot.hasData) { - final String? combined = - snapshot.data?.map((Directory d) => d.path).join(', '); + final String combined = + snapshot.data.map((Directory d) => d.path).join(', '); text = Text('paths: $combined'); } else { text = const Text('path unavailable'); @@ -134,7 +134,7 @@ class _MyHomePageState extends State { onPressed: _requestTempDirectory, ), ), - FutureBuilder( + FutureBuilder( future: _tempDirectory, builder: _buildDirectory), Padding( padding: const EdgeInsets.all(16.0), @@ -143,7 +143,7 @@ class _MyHomePageState extends State { onPressed: _requestAppDocumentsDirectory, ), ), - FutureBuilder( + FutureBuilder( future: _appDocumentsDirectory, builder: _buildDirectory), Padding( padding: const EdgeInsets.all(16.0), @@ -152,7 +152,7 @@ class _MyHomePageState extends State { onPressed: _requestAppSupportDirectory, ), ), - FutureBuilder( + FutureBuilder( future: _appSupportDirectory, builder: _buildDirectory), Padding( padding: const EdgeInsets.all(16.0), @@ -161,7 +161,7 @@ class _MyHomePageState extends State { onPressed: _requestAppLibraryDirectory, ), ), - FutureBuilder( + FutureBuilder( future: _appLibraryDirectory, builder: _buildDirectory), Padding( padding: const EdgeInsets.all(16.0), @@ -172,7 +172,7 @@ class _MyHomePageState extends State { Platform.isIOS ? null : _requestExternalStorageDirectory, ), ), - FutureBuilder( + FutureBuilder( future: _externalDocumentsDirectory, builder: _buildDirectory), Column(children: [ Padding( @@ -190,7 +190,7 @@ class _MyHomePageState extends State { ), ), ]), - FutureBuilder?>( + FutureBuilder>( future: _externalStorageDirectories, builder: _buildDirectories), Column(children: [ @@ -204,7 +204,7 @@ class _MyHomePageState extends State { ), ), ]), - FutureBuilder?>( + FutureBuilder>( future: _externalCacheDirectories, builder: _buildDirectories), ], ), diff --git a/packages/path_provider/path_provider/example/pubspec.yaml b/packages/path_provider/path_provider/example/pubspec.yaml index c6cba57cd23b..8659da753e15 100644 --- a/packages/path_provider/path_provider/example/pubspec.yaml +++ b/packages/path_provider/path_provider/example/pubspec.yaml @@ -12,11 +12,11 @@ dev_dependencies: path: ../../../integration_test flutter_driver: sdk: flutter - pedantic: ^1.10.0-nullsafety + pedantic: ^1.8.0 flutter: uses-material-design: true environment: - sdk: ">=2.12.0-0 <3.0.0" + sdk: ">=2.1.0 <3.0.0" flutter: ">=1.12.13+hotfix.5 <2.0.0" diff --git a/packages/path_provider/path_provider/example/test_driver/integration_test.dart b/packages/path_provider/path_provider/example/test_driver/integration_test.dart index ac106b63b339..7a2c21338786 100644 --- a/packages/path_provider/path_provider/example/test_driver/integration_test.dart +++ b/packages/path_provider/path_provider/example/test_driver/integration_test.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'dart:convert'; import 'dart:io'; diff --git a/packages/path_provider/path_provider/lib/path_provider.dart b/packages/path_provider/path_provider/lib/path_provider.dart index ae1fa8038966..1560c3399e72 100644 --- a/packages/path_provider/path_provider/lib/path_provider.dart +++ b/packages/path_provider/path_provider/lib/path_provider.dart @@ -29,8 +29,7 @@ PathProviderPlatform get _platform { // with a non-default instance. if (!kIsWeb && PathProviderPlatform.instance is MethodChannelPathProvider) { if (Platform.isLinux) { - // TODO: - //PathProviderPlatform.instance = PathProviderLinux(); + PathProviderPlatform.instance = PathProviderLinux(); } else if (Platform.isWindows) { PathProviderPlatform.instance = PathProviderWindows(); } diff --git a/packages/path_provider/path_provider/pubspec.yaml b/packages/path_provider/path_provider/pubspec.yaml index 28042b7c646a..6c4c851d8103 100644 --- a/packages/path_provider/path_provider/pubspec.yaml +++ b/packages/path_provider/path_provider/pubspec.yaml @@ -22,7 +22,7 @@ dependencies: flutter: sdk: flutter path_provider_platform_interface: ^2.0.0-nullsafety - path_provider_macos: ^0.0.4 + path_provider_macos: ^0.0.5-nullsafety path_provider_linux: ^0.2.0-nullsafety path_provider_windows: ^0.1.0-nullsafety From 3da050b1c73677c1fb3a0ff1025d62290f0f3d64 Mon Sep 17 00:00:00 2001 From: Maurice Parrish Date: Wed, 3 Feb 2021 18:25:53 -0800 Subject: [PATCH 5/5] use safety not safe in changelog --- packages/path_provider/path_provider/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/path_provider/path_provider/CHANGELOG.md b/packages/path_provider/path_provider/CHANGELOG.md index 982c7ad3e6ee..7364305333cf 100644 --- a/packages/path_provider/path_provider/CHANGELOG.md +++ b/packages/path_provider/path_provider/CHANGELOG.md @@ -1,6 +1,6 @@ ## 2.0.0-nullsafety -* Migrate to null safe. +* Migrate to null safety. ## 1.6.28