Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 982e1ca

Browse files
authoredFeb 19, 2021
[path_provider] Migrate examples to null-safety (#3559)
Allows running the examples in strong mode, even though the integration tests can't yet be. Converts the macOS example to use the platform interface, rather than the app-facing package, to eliminate the circular dependency. Also does some cleanup and simplification of the desktop example pubspecs. Does not update versions/changelogs since this won't be explicitly published, given that it's example-only.
1 parent fa95cde commit 982e1ca

File tree

21 files changed

+162
-239
lines changed

21 files changed

+162
-239
lines changed
 

‎packages/path_provider/path_provider/example/integration_test/path_provider_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
// @dart=2.9
6+
57
import 'dart:async';
68

79
import 'dart:io';

‎packages/path_provider/path_provider/example/lib/main.dart

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ class MyApp extends StatelessWidget {
2828
}
2929

3030
class MyHomePage extends StatefulWidget {
31-
MyHomePage({Key key, this.title}) : super(key: key);
31+
MyHomePage({Key? key, required this.title}) : super(key: key);
3232
final String title;
3333

3434
@override
3535
_MyHomePageState createState() => _MyHomePageState();
3636
}
3737

3838
class _MyHomePageState extends State<MyHomePage> {
39-
Future<Directory> _tempDirectory;
40-
Future<Directory> _appSupportDirectory;
41-
Future<Directory> _appLibraryDirectory;
42-
Future<Directory> _appDocumentsDirectory;
43-
Future<Directory> _externalDocumentsDirectory;
44-
Future<List<Directory>> _externalStorageDirectories;
45-
Future<List<Directory>> _externalCacheDirectories;
39+
Future<Directory?>? _tempDirectory;
40+
Future<Directory?>? _appSupportDirectory;
41+
Future<Directory?>? _appLibraryDirectory;
42+
Future<Directory?>? _appDocumentsDirectory;
43+
Future<Directory?>? _externalDocumentsDirectory;
44+
Future<List<Directory>?>? _externalStorageDirectories;
45+
Future<List<Directory>?>? _externalCacheDirectories;
4646

4747
void _requestTempDirectory() {
4848
setState(() {
@@ -51,13 +51,13 @@ class _MyHomePageState extends State<MyHomePage> {
5151
}
5252

5353
Widget _buildDirectory(
54-
BuildContext context, AsyncSnapshot<Directory> snapshot) {
54+
BuildContext context, AsyncSnapshot<Directory?> snapshot) {
5555
Text text = const Text('');
5656
if (snapshot.connectionState == ConnectionState.done) {
5757
if (snapshot.hasError) {
5858
text = Text('Error: ${snapshot.error}');
5959
} else if (snapshot.hasData) {
60-
text = Text('path: ${snapshot.data.path}');
60+
text = Text('path: ${snapshot.data!.path}');
6161
} else {
6262
text = const Text('path unavailable');
6363
}
@@ -66,14 +66,14 @@ class _MyHomePageState extends State<MyHomePage> {
6666
}
6767

6868
Widget _buildDirectories(
69-
BuildContext context, AsyncSnapshot<List<Directory>> snapshot) {
69+
BuildContext context, AsyncSnapshot<List<Directory>?> snapshot) {
7070
Text text = const Text('');
7171
if (snapshot.connectionState == ConnectionState.done) {
7272
if (snapshot.hasError) {
7373
text = Text('Error: ${snapshot.error}');
7474
} else if (snapshot.hasData) {
7575
final String combined =
76-
snapshot.data.map((Directory d) => d.path).join(', ');
76+
snapshot.data!.map((Directory d) => d.path).join(', ');
7777
text = Text('paths: $combined');
7878
} else {
7979
text = const Text('path unavailable');
@@ -134,7 +134,7 @@ class _MyHomePageState extends State<MyHomePage> {
134134
onPressed: _requestTempDirectory,
135135
),
136136
),
137-
FutureBuilder<Directory>(
137+
FutureBuilder<Directory?>(
138138
future: _tempDirectory, builder: _buildDirectory),
139139
Padding(
140140
padding: const EdgeInsets.all(16.0),
@@ -143,7 +143,7 @@ class _MyHomePageState extends State<MyHomePage> {
143143
onPressed: _requestAppDocumentsDirectory,
144144
),
145145
),
146-
FutureBuilder<Directory>(
146+
FutureBuilder<Directory?>(
147147
future: _appDocumentsDirectory, builder: _buildDirectory),
148148
Padding(
149149
padding: const EdgeInsets.all(16.0),
@@ -152,7 +152,7 @@ class _MyHomePageState extends State<MyHomePage> {
152152
onPressed: _requestAppSupportDirectory,
153153
),
154154
),
155-
FutureBuilder<Directory>(
155+
FutureBuilder<Directory?>(
156156
future: _appSupportDirectory, builder: _buildDirectory),
157157
Padding(
158158
padding: const EdgeInsets.all(16.0),
@@ -161,7 +161,7 @@ class _MyHomePageState extends State<MyHomePage> {
161161
onPressed: _requestAppLibraryDirectory,
162162
),
163163
),
164-
FutureBuilder<Directory>(
164+
FutureBuilder<Directory?>(
165165
future: _appLibraryDirectory, builder: _buildDirectory),
166166
Padding(
167167
padding: const EdgeInsets.all(16.0),
@@ -172,7 +172,7 @@ class _MyHomePageState extends State<MyHomePage> {
172172
Platform.isIOS ? null : _requestExternalStorageDirectory,
173173
),
174174
),
175-
FutureBuilder<Directory>(
175+
FutureBuilder<Directory?>(
176176
future: _externalDocumentsDirectory, builder: _buildDirectory),
177177
Column(children: <Widget>[
178178
Padding(
@@ -190,7 +190,7 @@ class _MyHomePageState extends State<MyHomePage> {
190190
),
191191
),
192192
]),
193-
FutureBuilder<List<Directory>>(
193+
FutureBuilder<List<Directory>?>(
194194
future: _externalStorageDirectories,
195195
builder: _buildDirectories),
196196
Column(children: <Widget>[
@@ -204,7 +204,7 @@ class _MyHomePageState extends State<MyHomePage> {
204204
),
205205
),
206206
]),
207-
FutureBuilder<List<Directory>>(
207+
FutureBuilder<List<Directory>?>(
208208
future: _externalCacheDirectories, builder: _buildDirectories),
209209
],
210210
),

‎packages/path_provider/path_provider/example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ flutter:
2323
uses-material-design: true
2424

2525
environment:
26-
sdk: ">=2.1.0 <3.0.0"
26+
sdk: ">=2.12.0-0 <3.0.0"
2727
flutter: ">=1.12.13+hotfix.5"

‎packages/path_provider/path_provider/example/test_driver/integration_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
// @dart=2.9
6+
57
import 'dart:async';
68
import 'dart:convert';
79
import 'dart:io';

‎packages/path_provider/path_provider_linux/example/integration_test/path_provider_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
// @dart=2.9
6+
57
import 'dart:io';
68
import 'package:flutter_test/flutter_test.dart';
79
import 'package:path_provider_linux/path_provider_linux.dart';

‎packages/path_provider/path_provider_linux/example/lib/main.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'dart:async';
44
import 'package:flutter/services.dart';
55
import 'package:path_provider_linux/path_provider_linux.dart';
66

7-
void main() async {
7+
void main() {
88
runApp(MyApp());
99
}
1010

@@ -15,10 +15,10 @@ class MyApp extends StatefulWidget {
1515
}
1616

1717
class _MyAppState extends State<MyApp> {
18-
String _tempDirectory = 'Unknown';
19-
String _downloadsDirectory = 'Unknown';
20-
String _appSupportDirectory = 'Unknown';
21-
String _documentsDirectory = 'Unknown';
18+
String? _tempDirectory = 'Unknown';
19+
String? _downloadsDirectory = 'Unknown';
20+
String? _appSupportDirectory = 'Unknown';
21+
String? _documentsDirectory = 'Unknown';
2222
final PathProviderLinux _provider = PathProviderLinux();
2323

2424
@override
@@ -29,10 +29,10 @@ class _MyAppState extends State<MyApp> {
2929

3030
// Platform messages are asynchronous, so we initialize in an async method.
3131
Future<void> initDirectories() async {
32-
String tempDirectory;
33-
String downloadsDirectory;
34-
String appSupportDirectory;
35-
String documentsDirectory;
32+
String? tempDirectory;
33+
String? downloadsDirectory;
34+
String? appSupportDirectory;
35+
String? documentsDirectory;
3636
// Platform messages may fail, so we use a try/catch PlatformException.
3737
try {
3838
tempDirectory = await _provider.getTemporaryPath();

‎packages/path_provider/path_provider_linux/example/pubspec.yaml

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,13 @@ description: Demonstrates how to use the path_provider_linux plugin.
33
publish_to: "none"
44

55
environment:
6-
sdk: ">=2.1.0 <3.0.0"
6+
sdk: ">=2.12.0-0 <3.0.0"
7+
flutter: ">=1.10.0"
78

89
dependencies:
910
flutter:
1011
sdk: flutter
1112

12-
path_provider_linux: any
13-
14-
# The following adds the Cupertino Icons font to your application.
15-
# Use with the CupertinoIcons class for iOS style icons.
16-
cupertino_icons: ^0.1.3
17-
18-
dependency_overrides:
1913
path_provider_linux:
2014
# When depending on this package from a real application you should use:
2115
# path_provider_linux: ^x.y.z
@@ -32,39 +26,5 @@ dev_dependencies:
3226
integration_test:
3327
path: ../../../integration_test
3428

35-
# For information on the generic Dart part of this file, see the
36-
# following page: https://dart.dev/tools/pub/pubspec
37-
38-
# The following section is specific to Flutter.
3929
flutter:
40-
# The following line ensures that the Material Icons font is
41-
# included with your application, so that you can use the icons in
42-
# the material Icons class.
4330
uses-material-design: true
44-
# To add assets to your application, add an assets section, like this:
45-
# assets:
46-
# - images/a_dot_burr.jpeg
47-
# - images/a_dot_ham.jpeg
48-
# An image asset can refer to one or more resolution-specific "variants", see
49-
# https://flutter.dev/assets-and-images/#resolution-aware.
50-
# For details regarding adding assets from package dependencies, see
51-
# https://flutter.dev/assets-and-images/#from-packages
52-
# To add custom fonts to your application, add a fonts section here,
53-
# in this "flutter" section. Each entry in this list should have a
54-
# "family" key with the font family name, and a "fonts" key with a
55-
# list giving the asset and other descriptors for the font. For
56-
# example:
57-
# fonts:
58-
# - family: Schyler
59-
# fonts:
60-
# - asset: fonts/Schyler-Regular.ttf
61-
# - asset: fonts/Schyler-Italic.ttf
62-
# style: italic
63-
# - family: Trajan Pro
64-
# fonts:
65-
# - asset: fonts/TrajanPro.ttf
66-
# - asset: fonts/TrajanPro_Bold.ttf
67-
# weight: 700
68-
#
69-
# For details regarding fonts from package dependencies,
70-
# see https://flutter.dev/custom-fonts/#from-packages

‎packages/path_provider/path_provider_linux/example/test/widget_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void main() {
3030
find.byWidgetPredicate(
3131
(Widget widget) =>
3232
widget is Text &&
33-
widget.data.startsWith('Temp Directory: /tmp'),
33+
widget.data!.startsWith('Temp Directory: /tmp'),
3434
),
3535
findsOneWidget,
3636
);
@@ -48,7 +48,7 @@ void main() {
4848
find.byWidgetPredicate(
4949
(Widget widget) =>
5050
widget is Text &&
51-
widget.data.startsWith('Documents Directory: /'),
51+
widget.data!.startsWith('Documents Directory: /'),
5252
),
5353
findsOneWidget,
5454
);
@@ -66,7 +66,7 @@ void main() {
6666
find.byWidgetPredicate(
6767
(Widget widget) =>
6868
widget is Text &&
69-
widget.data.startsWith('Downloads Directory: /'),
69+
widget.data!.startsWith('Downloads Directory: /'),
7070
),
7171
findsOneWidget,
7272
);
@@ -85,7 +85,7 @@ void main() {
8585
find.byWidgetPredicate(
8686
(Widget widget) =>
8787
widget is Text &&
88-
widget.data.startsWith('Application Support Directory: /'),
88+
widget.data!.startsWith('Application Support Directory: /'),
8989
),
9090
findsOneWidget,
9191
);

‎packages/path_provider/path_provider_linux/example/test_driver/integration_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
// @dart=2.9
6+
57
import 'dart:async';
68
import 'dart:convert';
79
import 'dart:io';

‎packages/path_provider/path_provider_macos/example/integration_test/path_provider_test.dart

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,56 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
// @dart=2.9
6+
57
import 'dart:io';
68
import 'package:flutter_test/flutter_test.dart';
7-
import 'package:path_provider/path_provider.dart';
9+
import 'package:path_provider_platform_interface/path_provider_platform_interface.dart';
810
import 'package:integration_test/integration_test.dart';
911

1012
void main() {
1113
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
1214

1315
testWidgets('getTemporaryDirectory', (WidgetTester tester) async {
14-
final Directory result = await getTemporaryDirectory();
16+
final PathProviderPlatform provider = PathProviderPlatform.instance;
17+
final String result = await provider.getTemporaryPath();
1518
_verifySampleFile(result, 'temporaryDirectory');
1619
});
1720

1821
testWidgets('getApplicationDocumentsDirectory', (WidgetTester tester) async {
19-
final Directory result = await getApplicationDocumentsDirectory();
22+
final PathProviderPlatform provider = PathProviderPlatform.instance;
23+
final String result = await provider.getApplicationDocumentsPath();
2024
_verifySampleFile(result, 'applicationDocuments');
2125
});
2226

2327
testWidgets('getApplicationSupportDirectory', (WidgetTester tester) async {
24-
final Directory result = await getApplicationSupportDirectory();
28+
final PathProviderPlatform provider = PathProviderPlatform.instance;
29+
final String result = await provider.getApplicationSupportPath();
2530
_verifySampleFile(result, 'applicationSupport');
2631
});
2732

2833
testWidgets('getLibraryDirectory', (WidgetTester tester) async {
29-
if (!Platform.isMacOS) {
30-
return;
31-
}
32-
final Directory result = await getLibraryDirectory();
34+
final PathProviderPlatform provider = PathProviderPlatform.instance;
35+
final String result = await provider.getLibraryPath();
3336
_verifySampleFile(result, 'library');
3437
});
38+
39+
testWidgets('getDownloadsDirectory', (WidgetTester tester) async {
40+
final PathProviderPlatform provider = PathProviderPlatform.instance;
41+
final String result = await provider.getDownloadsPath();
42+
// _verifySampleFile causes hangs in driver for some reason, so just
43+
// validate that a non-empty path was returned.
44+
expect(result, isNotEmpty);
45+
});
3546
}
3647

37-
/// Verify a file called [name] in [directory] by recreating it with test
48+
/// Verify a file called [name] in [directoryPath] by recreating it with test
3849
/// contents when necessary.
39-
void _verifySampleFile(Directory directory, String name) {
40-
final File file = File('${directory.path}/$name');
50+
///
51+
/// If [createDirectory] is true, the directory will be created if missing.
52+
void _verifySampleFile(String directoryPath, String name) {
53+
final Directory directory = Directory(directoryPath);
54+
final File file = File('${directory.path}${Platform.pathSeparator}$name');
4155

4256
if (file.existsSync()) {
4357
file.deleteSync();

‎packages/path_provider/path_provider_macos/example/lib/main.dart

Lines changed: 57 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -5,143 +5,87 @@
55
// ignore_for_file: public_member_api_docs
66

77
import 'dart:async';
8-
import 'dart:io' show Directory;
98

109
import 'package:flutter/material.dart';
11-
import 'package:path_provider/path_provider.dart';
10+
import 'package:path_provider_platform_interface/path_provider_platform_interface.dart';
1211

1312
void main() {
1413
runApp(MyApp());
1514
}
1615

17-
class MyApp extends StatelessWidget {
16+
/// Sample app
17+
class MyApp extends StatefulWidget {
1818
@override
19-
Widget build(BuildContext context) {
20-
return MaterialApp(
21-
title: 'Path Provider',
22-
theme: ThemeData(
23-
primarySwatch: Colors.blue,
24-
),
25-
home: MyHomePage(title: 'Path Provider'),
26-
);
27-
}
19+
_MyAppState createState() => _MyAppState();
2820
}
2921

30-
class MyHomePage extends StatefulWidget {
31-
MyHomePage({Key key, this.title}) : super(key: key);
32-
final String title;
22+
class _MyAppState extends State<MyApp> {
23+
String? _tempDirectory = 'Unknown';
24+
String? _downloadsDirectory = 'Unknown';
25+
String? _appSupportDirectory = 'Unknown';
26+
String? _documentsDirectory = 'Unknown';
3327

3428
@override
35-
_MyHomePageState createState() => _MyHomePageState();
36-
}
37-
38-
class _MyHomePageState extends State<MyHomePage> {
39-
Future<Directory> _tempDirectory;
40-
Future<Directory> _appSupportDirectory;
41-
Future<Directory> _appDocumentsDirectory;
42-
Future<Directory> _appLibraryDirectory;
43-
Future<Directory> _downloadsDirectory;
44-
45-
void _requestTempDirectory() {
46-
setState(() {
47-
_tempDirectory = getTemporaryDirectory();
48-
});
29+
void initState() {
30+
super.initState();
31+
initDirectories();
4932
}
5033

51-
Widget _buildDirectory(
52-
BuildContext context, AsyncSnapshot<Directory> snapshot) {
53-
Text text = const Text('');
54-
if (snapshot.connectionState == ConnectionState.done) {
55-
if (snapshot.hasError) {
56-
text = Text('Error: ${snapshot.error}');
57-
} else if (snapshot.hasData) {
58-
text = Text('path: ${snapshot.data.path}');
59-
} else {
60-
text = const Text('path unavailable');
61-
}
62-
}
63-
return Padding(padding: const EdgeInsets.all(16.0), child: text);
64-
}
34+
// Platform messages are asynchronous, so we initialize in an async method.
35+
Future<void> initDirectories() async {
36+
String? tempDirectory;
37+
String? downloadsDirectory;
38+
String? appSupportDirectory;
39+
String? documentsDirectory;
40+
final PathProviderPlatform provider = PathProviderPlatform.instance;
6541

66-
void _requestAppDocumentsDirectory() {
67-
setState(() {
68-
_appDocumentsDirectory = getApplicationDocumentsDirectory();
69-
});
70-
}
42+
try {
43+
tempDirectory = await provider.getTemporaryPath();
44+
} catch (exception) {
45+
tempDirectory = 'Failed to get temp directory: $exception';
46+
}
47+
try {
48+
downloadsDirectory = await provider.getDownloadsPath();
49+
} catch (exception) {
50+
downloadsDirectory = 'Failed to get downloads directory: $exception';
51+
}
7152

72-
void _requestAppSupportDirectory() {
73-
setState(() {
74-
_appSupportDirectory = getApplicationSupportDirectory();
75-
});
76-
}
53+
try {
54+
documentsDirectory = await provider.getApplicationDocumentsPath();
55+
} catch (exception) {
56+
documentsDirectory = 'Failed to get documents directory: $exception';
57+
}
7758

78-
void _requestAppLibraryDirectory() {
79-
setState(() {
80-
_appLibraryDirectory = getLibraryDirectory();
81-
});
82-
}
59+
try {
60+
appSupportDirectory = await provider.getApplicationSupportPath();
61+
} catch (exception) {
62+
appSupportDirectory = 'Failed to get app support directory: $exception';
63+
}
8364

84-
void _requestDownloadsDirectory() {
8565
setState(() {
86-
_downloadsDirectory = getDownloadsDirectory();
66+
_tempDirectory = tempDirectory;
67+
_downloadsDirectory = downloadsDirectory;
68+
_appSupportDirectory = appSupportDirectory;
69+
_documentsDirectory = documentsDirectory;
8770
});
8871
}
8972

9073
@override
9174
Widget build(BuildContext context) {
92-
return Scaffold(
93-
appBar: AppBar(
94-
title: Text(widget.title),
95-
),
96-
body: Center(
97-
child: ListView(
98-
children: <Widget>[
99-
Padding(
100-
padding: const EdgeInsets.all(16.0),
101-
child: ElevatedButton(
102-
child: const Text('Get Temporary Directory'),
103-
onPressed: _requestTempDirectory,
104-
),
105-
),
106-
FutureBuilder<Directory>(
107-
future: _tempDirectory, builder: _buildDirectory),
108-
Padding(
109-
padding: const EdgeInsets.all(16.0),
110-
child: ElevatedButton(
111-
child: const Text('Get Application Documents Directory'),
112-
onPressed: _requestAppDocumentsDirectory,
113-
),
114-
),
115-
FutureBuilder<Directory>(
116-
future: _appDocumentsDirectory, builder: _buildDirectory),
117-
Padding(
118-
padding: const EdgeInsets.all(16.0),
119-
child: ElevatedButton(
120-
child: const Text('Get Application Support Directory'),
121-
onPressed: _requestAppSupportDirectory,
122-
),
123-
),
124-
FutureBuilder<Directory>(
125-
future: _appSupportDirectory, builder: _buildDirectory),
126-
Padding(
127-
padding: const EdgeInsets.all(16.0),
128-
child: ElevatedButton(
129-
child: const Text('Get Application Library Directory'),
130-
onPressed: _requestAppLibraryDirectory,
131-
),
132-
),
133-
FutureBuilder<Directory>(
134-
future: _appLibraryDirectory, builder: _buildDirectory),
135-
Padding(
136-
padding: const EdgeInsets.all(16.0),
137-
child: ElevatedButton(
138-
child: const Text('Get Downlads Directory'),
139-
onPressed: _requestDownloadsDirectory,
140-
),
141-
),
142-
FutureBuilder<Directory>(
143-
future: _downloadsDirectory, builder: _buildDirectory),
144-
],
75+
return MaterialApp(
76+
home: Scaffold(
77+
appBar: AppBar(
78+
title: const Text('Path Provider example app'),
79+
),
80+
body: Center(
81+
child: Column(
82+
children: [
83+
Text('Temp Directory: $_tempDirectory\n'),
84+
Text('Documents Directory: $_documentsDirectory\n'),
85+
Text('Downloads Directory: $_downloadsDirectory\n'),
86+
Text('Application Support Directory: $_appSupportDirectory\n'),
87+
],
88+
),
14589
),
14690
),
14791
);

‎packages/path_provider/path_provider_macos/example/macos/Runner.xcodeproj/project.pbxproj

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
2828
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
2929
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
30-
33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; };
31-
33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
32-
D73912F022F37F9E000D13A0 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; };
33-
D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
3430
/* End PBXBuildFile section */
3531

3632
/* Begin PBXContainerItemProxy section */
@@ -50,8 +46,6 @@
5046
dstPath = "";
5147
dstSubfolderSpec = 10;
5248
files = (
53-
D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */,
54-
33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */,
5549
);
5650
name = "Bundle Framework";
5751
runOnlyForDeploymentPostprocessing = 0;
@@ -72,14 +66,12 @@
7266
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = "<group>"; };
7367
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = "<group>"; };
7468
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = "<group>"; };
75-
33D1A10322148B71006C7A3E /* FlutterMacOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FlutterMacOS.framework; path = Flutter/ephemeral/FlutterMacOS.framework; sourceTree = SOURCE_ROOT; };
7669
33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = "<group>"; };
7770
33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; };
7871
33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; };
7972
46139048DB9F59D473B61B5E /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
8073
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
8174
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
82-
D73912EF22F37F9E000D13A0 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/ephemeral/App.framework; sourceTree = SOURCE_ROOT; };
8375
F4586DA69948E3A954A2FC9C /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
8476
/* End PBXFileReference section */
8577

@@ -88,8 +80,6 @@
8880
isa = PBXFrameworksBuildPhase;
8981
buildActionMask = 2147483647;
9082
files = (
91-
D73912F022F37F9E000D13A0 /* App.framework in Frameworks */,
92-
33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */,
9383
23F6FAA3AF82DFCF2B7DD79A /* Pods_Runner.framework in Frameworks */,
9484
);
9585
runOnlyForDeploymentPostprocessing = 0;
@@ -156,8 +146,6 @@
156146
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */,
157147
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */,
158148
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */,
159-
D73912EF22F37F9E000D13A0 /* App.framework */,
160-
33D1A10322148B71006C7A3E /* FlutterMacOS.framework */,
161149
);
162150
path = Flutter;
163151
sourceTree = "<group>";
@@ -281,7 +269,7 @@
281269
);
282270
runOnlyForDeploymentPostprocessing = 0;
283271
shellPath = /bin/sh;
284-
shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename\n";
272+
shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n";
285273
};
286274
33CC111E2044C6BF0003C045 /* ShellScript */ = {
287275
isa = PBXShellScriptBuildPhase;
@@ -308,10 +296,13 @@
308296
buildActionMask = 2147483647;
309297
files = (
310298
);
311-
inputFileListPaths = (
299+
inputPaths = (
300+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
301+
"${BUILT_PRODUCTS_DIR}/path_provider_macos/path_provider_macos.framework",
312302
);
313303
name = "[CP] Embed Pods Frameworks";
314-
outputFileListPaths = (
304+
outputPaths = (
305+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_macos.framework",
315306
);
316307
runOnlyForDeploymentPostprocessing = 0;
317308
shellPath = /bin/sh;

‎packages/path_provider/path_provider_macos/example/macos/Runner/DebugProfile.entitlements

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@
88
<true/>
99
<key>com.apple.security.network.server</key>
1010
<true/>
11+
<key>com.apple.security.files.downloads.read-write</key>
12+
<true/>
1113
</dict>
1214
</plist>

‎packages/path_provider/path_provider_macos/example/macos/Runner/Release.entitlements

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
<dict>
55
<key>com.apple.security.app-sandbox</key>
66
<true/>
7+
<key>com.apple.security.files.downloads.read-write</key>
8+
<true/>
79
</dict>
810
</plist>

‎packages/path_provider/path_provider_macos/example/pubspec.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@ description: Demonstrates how to use the path_provider plugin.
44
dependencies:
55
flutter:
66
sdk: flutter
7-
path_provider: ^1.6.14
8-
9-
# path_provider_macos is endorsed, so we need to add it to dependency_overrides
10-
# to depend on it from path:
11-
dependency_overrides:
127
path_provider_macos:
138
# When depending on this package from a real application you should use:
149
# path_provider_macos: ^x.y.z
1510
# See https://dart.dev/tools/pub/dependencies#version-constraints
1611
# The example app is bundled with the plugin so we use a path dependency on
1712
# the parent directory to use the current plugin's version.
1813
path: ../
14+
path_provider_platform_interface: 2.0.0-nullsafety
1915

2016
dev_dependencies:
2117
integration_test:
@@ -28,5 +24,5 @@ flutter:
2824
uses-material-design: true
2925

3026
environment:
31-
sdk: ">=2.1.0 <3.0.0"
27+
sdk: ">=2.12.0-0 <3.0.0"
3228
flutter: ">=1.10.0"

‎packages/path_provider/path_provider_macos/example/test_driver/integration_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
// @dart=2.9
6+
57
import 'dart:async';
68
import 'dart:convert';
79
import 'dart:io';

‎packages/path_provider/path_provider_windows/example/integration_test/path_provider_test.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
// @dart=2.9
6+
57
import 'dart:io';
68
import 'package:flutter_test/flutter_test.dart';
79
import 'package:path_provider_windows/path_provider_windows.dart';
8-
import 'package:e2e/e2e.dart';
10+
import 'package:integration_test/integration_test.dart';
911

1012
void main() {
11-
E2EWidgetsFlutterBinding.ensureInitialized();
13+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
1214

1315
testWidgets('getTemporaryDirectory', (WidgetTester tester) async {
1416
final PathProviderWindows provider = PathProviderWindows();

‎packages/path_provider/path_provider_windows/example/lib/main.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'dart:async';
99
import 'package:flutter/material.dart';
1010
import 'package:path_provider_windows/path_provider_windows.dart';
1111

12-
void main() async {
12+
void main() {
1313
runApp(MyApp());
1414
}
1515

@@ -20,10 +20,10 @@ class MyApp extends StatefulWidget {
2020
}
2121

2222
class _MyAppState extends State<MyApp> {
23-
String _tempDirectory = 'Unknown';
24-
String _downloadsDirectory = 'Unknown';
25-
String _appSupportDirectory = 'Unknown';
26-
String _documentsDirectory = 'Unknown';
23+
String? _tempDirectory = 'Unknown';
24+
String? _downloadsDirectory = 'Unknown';
25+
String? _appSupportDirectory = 'Unknown';
26+
String? _documentsDirectory = 'Unknown';
2727

2828
@override
2929
void initState() {
@@ -33,10 +33,10 @@ class _MyAppState extends State<MyApp> {
3333

3434
// Platform messages are asynchronous, so we initialize in an async method.
3535
Future<void> initDirectories() async {
36-
String tempDirectory;
37-
String downloadsDirectory;
38-
String appSupportDirectory;
39-
String documentsDirectory;
36+
String? tempDirectory;
37+
String? downloadsDirectory;
38+
String? appSupportDirectory;
39+
String? documentsDirectory;
4040
final PathProviderWindows provider = PathProviderWindows();
4141

4242
try {

‎packages/path_provider/path_provider_windows/example/pubspec.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ description: Demonstrates how to use the path_provider plugin.
44
dependencies:
55
flutter:
66
sdk: flutter
7-
path_provider_windows: any
8-
9-
dependency_overrides:
107
path_provider_windows:
118
# When depending on this package from a real application you should use:
129
# path_provider_windows: ^x.y.z
@@ -16,7 +13,8 @@ dependency_overrides:
1613
path: ../
1714

1815
dev_dependencies:
19-
e2e: ^0.2.1
16+
integration_test:
17+
path: ../../../integration_test
2018
flutter_driver:
2119
sdk: flutter
2220
pedantic: ^1.8.0
@@ -25,5 +23,5 @@ flutter:
2523
uses-material-design: true
2624

2725
environment:
28-
sdk: ">=2.1.0 <3.0.0"
26+
sdk: ">=2.12.0-0 <3.0.0"
2927
flutter: ">=1.12.13+hotfix.4"

‎packages/path_provider/path_provider_windows/example/test_driver/integration_test.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
// @dart=2.9
6+
57
import 'dart:async';
8+
import 'dart:convert';
69
import 'dart:io';
710
import 'package:flutter_driver/flutter_driver.dart';
811

912
Future<void> main() async {
1013
final FlutterDriver driver = await FlutterDriver.connect();
11-
final String result =
14+
final String data =
1215
await driver.requestData(null, timeout: const Duration(minutes: 1));
1316
await driver.close();
14-
exit(result == 'pass' ? 0 : 1);
17+
final Map<String, dynamic> result = jsonDecode(data);
18+
exit(result['result'] == 'true' ? 0 : 1);
1519
}

‎packages/path_provider/path_provider_windows/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ dev_dependencies:
2525
pedantic: ^1.10.0-nullsafety.3
2626

2727
environment:
28-
sdk: '>=2.12.0-259.8.beta <3.0.0'
28+
sdk: ">=2.12.0-0 <3.0.0"
2929
flutter: ">=1.12.13+hotfix.4"

0 commit comments

Comments
 (0)
Please sign in to comment.