flutter: невозможно скопировать dile улья в хранилище с помощью file.copy

Я пытаюсь скопировать улей в мобильное хранилище. После принятия достаточных разрешений я запускаю свой метод:

        Future<void> exportVocabsDb() async {
    final dir = await getExternalStorageDirectory();
    final evbDirectory =
        await Directory('${dir!.path}/evb').create(recursive: true);
    hiveService.backupHiveBox<VocabularyModel>(
        VOCABULARY_BOX, evbDirectory.path);
  }

и :

        Future<void> backupHiveBox<T>(String boxName, String backupPath) async {
    if (!Hive.isBoxOpen(boxName)) {}
    final box = await Hive.openBox<T>(boxName);
    final boxPath = box.path;
    await box.close();

    try {
      File('$boxPath-${DateTime.now().toUtc().toIso8601String()}')
          .copy(backupPath);
    } finally {
      await Hive.openBox<T>(boxName);
    }
  }

Но я получил такую ​​ошибку:

      [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: FileSystemException: Cannot copy file to '/storage/emulated/0/Android/data/com.example.english_vocabulary_builder/files/evb', path = '/data/user/0/com.example.english_vocabulary_builder/app_flutter/vocabularybox.hive-2021-07-31T09:45:10.236593Z' (OS Error: No such file or directory, errno = 2)

это доктор:

      Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.3, on Linux, locale en_US.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] Android Studio
[✓] VS Code (version 1.58.2)
[✓] Connected device (2 available)

! Doctor found issues in 1 category.

0 ответов

Другие вопросы по тегам