Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振FileSystemException(FileSystemException:创建失败) static Future init()异步{ var installPath=“/Users/purplecity/code/likai_flatter/beiwanglu”; 目录notePath=目录(${installPath}/NoteStorage/”; var noteDir=await notePath.exists(); 如果(!noteDir){ 等待notePath.create(); }_Flutter - Fatal编程技术网

Flutter 颤振FileSystemException(FileSystemException:创建失败) static Future init()异步{ var installPath=“/Users/purplecity/code/likai_flatter/beiwanglu”; 目录notePath=目录(${installPath}/NoteStorage/”; var noteDir=await notePath.exists(); 如果(!noteDir){ 等待notePath.create(); }

Flutter 颤振FileSystemException(FileSystemException:创建失败) static Future init()异步{ var installPath=“/Users/purplecity/code/likai_flatter/beiwanglu”; 目录notePath=目录(${installPath}/NoteStorage/”; var noteDir=await notePath.exists(); 如果(!noteDir){ 等待notePath.create(); },flutter,Flutter,在Flatter设备:ios emulator上可以,但在设备:Android-x86 emulator上有错误 我需要做什么?我不想使用资产..只要读取本地文件 Error: FileSystemException (FileSystemException: Creation failed, path = '/Users/purplecity/Library/Android/sdk/NoteStorage/' (OS Error: No such file or directory, err

在Flatter设备:ios emulator上可以,但在设备:Android-x86 emulator上有错误

我需要做什么?我不想使用资产..只要读取本地文件

Error:

FileSystemException (FileSystemException: Creation failed, path = '/Users/purplecity/Library/Android/sdk/NoteStorage/' (OS Error: No such file or directory, errno = 2))

flatter允许您将资产(包括json等)放入应用程序。您手动执行此操作可能会导致此问题

在pubspec.yaml中尝试以下操作

  flutter:
   assets:
     - NoteStorage/ 
确保识别是完美的,pubspec.yaml对此非常敏感。

然后,您可以使用以下方法加载资源:

import 'dart:async' show Future;
import 'package:flutter/services.dart' show rootBundle;

Future<String> loadAsset() async {
  return await rootBundle.loadString('assets/NoteStorage/b1.json');
}
导入'dart:async'显示未来;
导入“包:flatter/services.dart”显示根包;
Future loadAsset()异步{
return wait-rootBundle.loadString('assets/notestage/b1.json');
}

谢谢!我尝试编写一个便笺应用程序。我存储的便笺文本使用json格式文件。因此,如果我添加了一个新便笺,那么需要创建一个新的json文件。它将在NoteStorage/?创建,我认为这不会对资产起作用,因为它们是虚拟的。路径实际上并不存在。在您的情况下,我会看看这一点:如果“创建失败”ain,你可能需要更多Android权限。谢谢,我去看看你测试应用程序的Android版本,这个
/Users/purplecity/code/likai_flatter/beiwanglu
不是有效的存储路径。