Browse Source

Merge pull request #1039 from nextcloud/refactor/universal_io

Use universal_io instead of dart:io
pull/1042/head
Kate 1 year ago committed by GitHub
parent
commit
ce4cf08478
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      .github/workflows/neon.yml
  2. 3
      packages/app/integration_test/screenshot_test.dart
  3. 2
      packages/app/pubspec.lock
  4. 1
      packages/app/pubspec.yaml
  5. 2
      packages/neon/neon/lib/src/app.dart
  6. 3
      packages/neon/neon/lib/src/platform/linux.dart
  7. 2
      packages/neon/neon/lib/src/platform/platform.dart
  8. 3
      packages/neon/neon/lib/src/utils/global_options.dart
  9. 2
      packages/neon/neon/lib/src/utils/save_file.dart
  10. 2
      packages/neon/neon/lib/src/widgets/error.dart
  11. 1
      packages/neon/neon/pubspec.yaml
  12. 2
      packages/neon/neon_files/lib/neon_files.dart
  13. 1
      packages/neon/neon_files/pubspec.yaml
  14. 2
      packages/nextcloud/test/helper.dart
  15. 2
      packages/nextcloud/test/news_test.dart
  16. 2
      packages/nextcloud/test/webdav_test.dart
  17. 10
      tool/find-dart-io-usage.sh

10
.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

3
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<void> runTestApp(
final WidgetTester tester,

2
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"

1
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:

2
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

3
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

2
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

3
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';

2
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<String?> saveFileWithPickDialog(final String fileName, final Uint8List data) async {
if (NeonPlatform.instance.shouldUseFileDialog) {

2
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.
///

1
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

2
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';

1
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

2
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));

2
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';

2
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';

10
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
Loading…
Cancel
Save