@@ -36,14 +36,14 @@ void main() {
3636 _verifySampleFile (result, 'library' );
3737 } else if (Platform .isAndroid) {
3838 final Future <Directory ?> result = getLibraryDirectory ();
39- expect (result, throwsA (isInstanceOf <UnsupportedError >()));
39+ await expectLater (result, throwsA (isInstanceOf <UnsupportedError >()));
4040 }
4141 });
4242
4343 testWidgets ('getExternalStorageDirectory' , (WidgetTester tester) async {
4444 if (Platform .isIOS) {
4545 final Future <Directory ?> result = getExternalStorageDirectory ();
46- expect (result, throwsA (isInstanceOf <UnsupportedError >()));
46+ await expectLater (result, throwsA (isInstanceOf <UnsupportedError >()));
4747 } else if (Platform .isAndroid) {
4848 final Directory ? result = await getExternalStorageDirectory ();
4949 _verifySampleFile (result, 'externalStorage' );
@@ -53,7 +53,7 @@ void main() {
5353 testWidgets ('getExternalCacheDirectories' , (WidgetTester tester) async {
5454 if (Platform .isIOS) {
5555 final Future <List <Directory >?> result = getExternalCacheDirectories ();
56- expect (result, throwsA (isInstanceOf <UnsupportedError >()));
56+ await expectLater (result, throwsA (isInstanceOf <UnsupportedError >()));
5757 } else if (Platform .isAndroid) {
5858 final List <Directory >? directories = await getExternalCacheDirectories ();
5959 expect (directories, isNotNull);
@@ -79,7 +79,7 @@ void main() {
7979 (WidgetTester tester) async {
8080 if (Platform .isIOS) {
8181 final Future <List <Directory >?> result = getExternalStorageDirectories ();
82- expect (result, throwsA (isInstanceOf <UnsupportedError >()));
82+ await expectLater (result, throwsA (isInstanceOf <UnsupportedError >()));
8383 } else if (Platform .isAndroid) {
8484 final List <Directory >? directories =
8585 await getExternalStorageDirectories (type: type);
@@ -92,17 +92,12 @@ void main() {
9292 }
9393
9494 testWidgets ('getDownloadsDirectory' , (WidgetTester tester) async {
95- if (Platform .isAndroid) {
96- final Future <Directory ?> result = getDownloadsDirectory ();
97- expect (result, throwsA (isInstanceOf <UnsupportedError >()));
98- } else {
99- final Directory ? result = await getDownloadsDirectory ();
100- // On recent versions of macOS, actually using the downloads directory
101- // requires a user prompt (so will fail on CI), and on some platforms the
102- // directory may not exist. Instead of verifying that it exists, just
103- // check that it returned a path.
104- expect (result? .path, isNotEmpty);
105- }
95+ final Directory ? result = await getDownloadsDirectory ();
96+ // On recent versions of macOS, actually using the downloads directory
97+ // requires a user prompt (so will fail on CI), and on some platforms the
98+ // directory may not exist. Instead of verifying that it exists, just
99+ // check that it returned a path.
100+ expect (result? .path, isNotEmpty);
106101 });
107102}
108103
0 commit comments