diff --git a/.github/workflows/neon.yml b/.github/workflows/neon.yml index cd5afb3d..e4f213eb 100644 --- a/.github/workflows/neon.yml +++ b/.github/workflows/neon.yml @@ -19,3 +19,13 @@ jobs: - name: Find untested Neon APIs run: ./tool/find-untested-neon-apis.sh + + dart-io-usage: + name: dart:io usage + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + + - name: Find dart:io usage + run: ./tool/find-dart-io-usage.sh diff --git a/packages/app/integration_test/screenshot_test.dart b/packages/app/integration_test/screenshot_test.dart index ca0078d4..d4e22fa5 100644 --- a/packages/app/integration_test/screenshot_test.dart +++ b/packages/app/integration_test/screenshot_test.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:app/apps.dart'; import 'package:app/branding.dart'; import 'package:flutter/material.dart'; @@ -17,6 +15,7 @@ import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/notes.dart' as notes; import 'package:nextcloud/notifications.dart' as notifications; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:universal_io/io.dart'; Future runTestApp( final WidgetTester tester, diff --git a/packages/app/pubspec.lock b/packages/app/pubspec.lock index e814f974..4ae72297 100644 --- a/packages/app/pubspec.lock +++ b/packages/app/pubspec.lock @@ -1231,7 +1231,7 @@ packages: source: hosted version: "2.0.1" universal_io: - dependency: transitive + dependency: "direct main" description: name: universal_io sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad" diff --git a/packages/app/pubspec.yaml b/packages/app/pubspec.yaml index 0f014f51..1275b13c 100644 --- a/packages/app/pubspec.yaml +++ b/packages/app/pubspec.yaml @@ -33,6 +33,7 @@ dependencies: git: url: https://github.com/nextcloud/neon path: packages/neon/neon_notifications + universal_io: any vector_graphics: any dev_dependencies: diff --git a/packages/neon/neon/lib/src/app.dart b/packages/neon/neon/lib/src/app.dart index 42a61086..1726389e 100644 --- a/packages/neon/neon/lib/src/app.dart +++ b/packages/neon/neon/lib/src/app.dart @@ -1,6 +1,5 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:io'; import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; @@ -27,6 +26,7 @@ import 'package:nextcloud/core.dart' as core; import 'package:nextcloud/nextcloud.dart'; import 'package:quick_actions/quick_actions.dart'; import 'package:tray_manager/tray_manager.dart' as tray; +import 'package:universal_io/io.dart'; import 'package:window_manager/window_manager.dart'; @internal diff --git a/packages/neon/neon/lib/src/platform/linux.dart b/packages/neon/neon/lib/src/platform/linux.dart index 4c3f5b2c..b244f390 100644 --- a/packages/neon/neon/lib/src/platform/linux.dart +++ b/packages/neon/neon/lib/src/platform/linux.dart @@ -1,9 +1,8 @@ -import 'dart:io'; - import 'package:meta/meta.dart'; import 'package:neon/src/platform/platform.dart'; import 'package:path/path.dart' as p; import 'package:sqflite_common_ffi/sqflite_ffi.dart'; +import 'package:universal_io/io.dart'; @immutable @internal diff --git a/packages/neon/neon/lib/src/platform/platform.dart b/packages/neon/neon/lib/src/platform/platform.dart index 6393ea2a..ad96413d 100644 --- a/packages/neon/neon/lib/src/platform/platform.dart +++ b/packages/neon/neon/lib/src/platform/platform.dart @@ -1,9 +1,9 @@ import 'dart:async'; -import 'dart:io'; import 'package:meta/meta.dart'; import 'package:neon/src/platform/android.dart'; import 'package:neon/src/platform/linux.dart'; +import 'package:universal_io/io.dart'; /// Implements platform specific functionality and exposes the availability of certain features. @immutable diff --git a/packages/neon/neon/lib/src/utils/global_options.dart b/packages/neon/neon/lib/src/utils/global_options.dart index c2d93699..99e190d9 100644 --- a/packages/neon/neon/lib/src/utils/global_options.dart +++ b/packages/neon/neon/lib/src/utils/global_options.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:meta/meta.dart'; import 'package:neon/l10n/localizations.dart'; @@ -10,6 +8,7 @@ import 'package:neon/src/settings/models/options_collection.dart'; import 'package:neon/src/settings/models/storage.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:permission_handler/permission_handler.dart'; +import 'package:universal_io/io.dart'; const unifiedPushNextPushID = 'org.unifiedpush.distributor.nextpush'; diff --git a/packages/neon/neon/lib/src/utils/save_file.dart b/packages/neon/neon/lib/src/utils/save_file.dart index 36b27c83..b265d881 100644 --- a/packages/neon/neon/lib/src/utils/save_file.dart +++ b/packages/neon/neon/lib/src/utils/save_file.dart @@ -1,9 +1,9 @@ -import 'dart:io'; import 'dart:typed_data'; import 'package:file_picker/file_picker.dart'; import 'package:flutter_file_dialog/flutter_file_dialog.dart'; import 'package:neon/src/platform/platform.dart'; +import 'package:universal_io/io.dart'; Future saveFileWithPickDialog(final String fileName, final Uint8List data) async { if (NeonPlatform.instance.shouldUseFileDialog) { diff --git a/packages/neon/neon/lib/src/widgets/error.dart b/packages/neon/neon/lib/src/widgets/error.dart index 073469aa..70fc5947 100644 --- a/packages/neon/neon/lib/src/widgets/error.dart +++ b/packages/neon/neon/lib/src/widgets/error.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:io'; import 'package:flutter/material.dart'; import 'package:http/http.dart'; @@ -10,6 +9,7 @@ import 'package:neon/src/router.dart'; import 'package:neon/src/utils/exceptions.dart'; import 'package:neon/src/utils/provider.dart'; import 'package:nextcloud/nextcloud.dart'; +import 'package:universal_io/io.dart'; /// An indicator that an [error] has occurred. /// diff --git a/packages/neon/neon/pubspec.yaml b/packages/neon/neon/pubspec.yaml index acdaf8d8..1d5fc229 100644 --- a/packages/neon/neon/pubspec.yaml +++ b/packages/neon/neon/pubspec.yaml @@ -51,6 +51,7 @@ dependencies: tray_manager: ^0.2.0 unifiedpush: ^5.0.0 unifiedpush_android: ^2.0.0 + universal_io: ^2.0.0 url_launcher: ^6.1.0 vector_graphics: ^1.0.0 window_manager: ^0.3.0 diff --git a/packages/neon/neon_files/lib/neon_files.dart b/packages/neon/neon_files/lib/neon_files.dart index 739242f2..d6df44da 100644 --- a/packages/neon/neon_files/lib/neon_files.dart +++ b/packages/neon/neon_files/lib/neon_files.dart @@ -1,7 +1,6 @@ library neon_files; import 'dart:async'; -import 'dart:io'; import 'package:collection/collection.dart'; import 'package:file_icons/file_icons.dart'; @@ -30,6 +29,7 @@ import 'package:path_provider/path_provider.dart'; import 'package:queue/queue.dart'; import 'package:rxdart/rxdart.dart'; import 'package:share_plus/share_plus.dart'; +import 'package:universal_io/io.dart'; part 'blocs/browser.dart'; part 'blocs/files.dart'; diff --git a/packages/neon/neon_files/pubspec.yaml b/packages/neon/neon_files/pubspec.yaml index 249c3761..75cab273 100644 --- a/packages/neon/neon_files/pubspec.yaml +++ b/packages/neon/neon_files/pubspec.yaml @@ -36,6 +36,7 @@ dependencies: queue: ^3.0.0 rxdart: ^0.27.0 share_plus: ^7.0.0 + universal_io: ^2.0.0 dev_dependencies: build_runner: ^2.4.6 diff --git a/packages/nextcloud/test/helper.dart b/packages/nextcloud/test/helper.dart index 9d950ff6..17044868 100644 --- a/packages/nextcloud/test/helper.dart +++ b/packages/nextcloud/test/helper.dart @@ -1,12 +1,12 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:io'; import 'dart:math'; import 'package:nextcloud/core.dart' as core; import 'package:nextcloud/nextcloud.dart'; import 'package:process_run/cmd_run.dart'; import 'package:test/test.dart'; +import 'package:universal_io/io.dart'; const retryCount = 3; const timeout = Timeout(Duration(seconds: 30)); diff --git a/packages/nextcloud/test/news_test.dart b/packages/nextcloud/test/news_test.dart index 5664f425..7ca96f47 100644 --- a/packages/nextcloud/test/news_test.dart +++ b/packages/nextcloud/test/news_test.dart @@ -1,9 +1,9 @@ import 'dart:async'; -import 'dart:io'; import 'package:nextcloud/news.dart' as news; import 'package:nextcloud/nextcloud.dart'; import 'package:test/test.dart'; +import 'package:universal_io/io.dart'; import 'helper.dart'; diff --git a/packages/nextcloud/test/webdav_test.dart b/packages/nextcloud/test/webdav_test.dart index 0ac3d0ef..bfc3eeea 100644 --- a/packages/nextcloud/test/webdav_test.dart +++ b/packages/nextcloud/test/webdav_test.dart @@ -1,10 +1,10 @@ import 'dart:convert'; -import 'dart:io'; import 'dart:math'; import 'dart:typed_data'; import 'package:nextcloud/nextcloud.dart'; import 'package:test/test.dart'; +import 'package:universal_io/io.dart'; import 'helper.dart'; diff --git a/tool/find-dart-io-usage.sh b/tool/find-dart-io-usage.sh new file mode 100755 index 00000000..009d5cca --- /dev/null +++ b/tool/find-dart-io-usage.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -euxo pipefail +cd "$(dirname "$0")/.." + +dart_io_usage=("$(grep -r packages --include "*\.dart" -e "dart:io" -l | grep -v "/\.dart_tool/" | grep -v "/bin/" | grep -v "/test_driver/" || true)") + +if [[ -n "${dart_io_usage[*]}" ]]; then + printf "%s\n" "${dart_io_usage[@]}" + exit 1 +fi