path_provider: update for official packages/path_provider 2.2.0 (#68)
Signed-off-by: Hidenori Matsubayashi <[email protected]>
This commit is contained in:
@@ -36,6 +36,12 @@ void main() {
|
||||
final String? result = await provider.getApplicationSupportPath();
|
||||
_verifySampleFile(result, 'applicationSupport');
|
||||
});
|
||||
|
||||
testWidgets('getApplicationCacheDirectory', (WidgetTester tester) async {
|
||||
final PathProviderELinux provider = PathProviderELinux();
|
||||
final String? result = await provider.getApplicationCachePath();
|
||||
_verifySampleFile(result, 'applicationCache');
|
||||
});
|
||||
}
|
||||
|
||||
/// Verify a file called [name] in [directoryPath] by recreating it with test
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2021 Sony Group Corporation. All rights reserved.
|
||||
// Copyright 2023 Sony Group Corporation. All rights reserved.
|
||||
// Copyright 2013 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.
|
||||
@@ -13,14 +13,18 @@ void main() {
|
||||
|
||||
/// Sample app
|
||||
class MyApp extends StatefulWidget {
|
||||
/// Default Constructor
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
_MyAppState createState() => _MyAppState();
|
||||
State<MyApp> createState() => _MyAppState();
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> {
|
||||
String? _tempDirectory = 'Unknown';
|
||||
String? _downloadsDirectory = 'Unknown';
|
||||
String? _appSupportDirectory = 'Unknown';
|
||||
String? _appCacheDirectory = 'Unknown';
|
||||
String? _documentsDirectory = 'Unknown';
|
||||
final PathProviderELinux _provider = PathProviderELinux();
|
||||
|
||||
@@ -35,33 +39,36 @@ class _MyAppState extends State<MyApp> {
|
||||
String? tempDirectory;
|
||||
String? downloadsDirectory;
|
||||
String? appSupportDirectory;
|
||||
String? appCacheDirectory;
|
||||
String? documentsDirectory;
|
||||
// Platform messages may fail, so we use a try/catch PlatformException.
|
||||
try {
|
||||
tempDirectory = await _provider.getTemporaryPath();
|
||||
} on PlatformException catch (e, stackTrace) {
|
||||
} on PlatformException {
|
||||
tempDirectory = 'Failed to get temp directory.';
|
||||
print('$tempDirectory $e $stackTrace');
|
||||
}
|
||||
try {
|
||||
downloadsDirectory = await _provider.getDownloadsPath();
|
||||
} on PlatformException catch (e, stackTrace) {
|
||||
} on PlatformException {
|
||||
downloadsDirectory = 'Failed to get downloads directory.';
|
||||
print('$downloadsDirectory $e $stackTrace');
|
||||
}
|
||||
|
||||
try {
|
||||
documentsDirectory = await _provider.getApplicationDocumentsPath();
|
||||
} on PlatformException catch (e, stackTrace) {
|
||||
} on PlatformException {
|
||||
documentsDirectory = 'Failed to get documents directory.';
|
||||
print('$documentsDirectory $e $stackTrace');
|
||||
}
|
||||
|
||||
try {
|
||||
appSupportDirectory = await _provider.getApplicationSupportPath();
|
||||
} on PlatformException catch (e, stackTrace) {
|
||||
} on PlatformException {
|
||||
appSupportDirectory = 'Failed to get documents directory.';
|
||||
print('$appSupportDirectory $e $stackTrace');
|
||||
}
|
||||
|
||||
try {
|
||||
appCacheDirectory = await _provider.getApplicationCachePath();
|
||||
} on PlatformException {
|
||||
appCacheDirectory = 'Failed to get cache directory.';
|
||||
}
|
||||
// If the widget was removed from the tree while the asynchronous platform
|
||||
// message was in flight, we want to discard the reply rather than calling
|
||||
@@ -74,6 +81,7 @@ class _MyAppState extends State<MyApp> {
|
||||
_tempDirectory = tempDirectory;
|
||||
_downloadsDirectory = downloadsDirectory;
|
||||
_appSupportDirectory = appSupportDirectory;
|
||||
_appCacheDirectory = appCacheDirectory;
|
||||
_documentsDirectory = documentsDirectory;
|
||||
});
|
||||
}
|
||||
@@ -83,7 +91,7 @@ class _MyAppState extends State<MyApp> {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Path Provider eLinux example app'),
|
||||
title: const Text('Path Provider Linux example app'),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
@@ -92,6 +100,7 @@ class _MyAppState extends State<MyApp> {
|
||||
Text('Documents Directory: $_documentsDirectory\n'),
|
||||
Text('Downloads Directory: $_downloadsDirectory\n'),
|
||||
Text('Application Support Directory: $_appSupportDirectory\n'),
|
||||
Text('Application Cache Directory: $_appCacheDirectory\n'),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -3,8 +3,8 @@ description: Demonstrates how to use the path_provider_elinux plugin.
|
||||
publish_to: "none"
|
||||
|
||||
environment:
|
||||
sdk: ">=2.12.0 <3.0.0"
|
||||
flutter: ">=2.10.0"
|
||||
sdk: ">=2.18.0 <4.0.0"
|
||||
flutter: ">=3.3.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
@@ -14,8 +14,6 @@ dependencies:
|
||||
path: ../
|
||||
|
||||
dev_dependencies:
|
||||
flutter_driver:
|
||||
sdk: flutter
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
integration_test:
|
||||
|
||||
Reference in New Issue
Block a user