diff --git a/test/x_file_io_test.dart b/test/x_file_io_test.dart index 25f46a4eda..94ac81c4ca 100644 --- a/test/x_file_io_test.dart +++ b/test/x_file_io_test.dart @@ -11,17 +11,8 @@ import 'dart:typed_data'; import 'package:flutter_test/flutter_test.dart'; import 'package:cross_file/cross_file.dart'; -// Please note that executing this test with command -// `flutter test test/x_file_io_test.dart` will set the directory -// to ./file_selector_platform_interface. -// -// This will cause our hello.txt file to be not be found. Please -// execute this test with `flutter test` or change the path prefix -// to ./test/assets/ -// -// https://github.com/flutter/flutter/issues/20907 - -final pathPrefix = './assets/'; +final pathPrefix = + Directory.current.path.endsWith('test') ? './assets/' : './test/assets/'; final path = pathPrefix + 'hello.txt'; final String expectedStringContents = 'Hello, world!'; final Uint8List bytes = Uint8List.fromList(utf8.encode(expectedStringContents)); @@ -30,7 +21,7 @@ final String textFilePath = textFile.path; void main() { group('Create with a path', () { - final file = XFile(textFilePath); + final XFile file = XFile(textFilePath); test('Can be read as a string', () async { expect(await file.readAsString(), equals(expectedStringContents));