1

map_repository

     Future<MapModel> selectedMapJson(String searchMapName) async {
    List<MapModel> mapList = [];
    List<MapModel> selectedMapList = [];
    MapModel selectedMap;

    Directory directory = await getApplicationDocumentsDirectory();
    File file = File("${directory.path}/map_data.json");

    var contents = await json.decode(file.readAsStringSync());

    contents.forEach((e, v) {
      Map<String, dynamic> content = {e: v};
      Map<String, dynamic> data = content[e];

      mapList.add(MapModel.fromJson(data));
    });

    selectedMapList =
        mapList.where((e) => e.name!.contains(searchMapName)).toList();

    selectedMap = selectedMapList[0];

    return Future.value(selectedMap);
  }

tech_tree_repository

    Future<dynamic> selectedTechTreeJson(
      selectedTribe, selectedTechTreeName) async {
    List techTreeList = [];
    late List selectedtechTreeList;
    late var selectedTechTree;
    late var techTreeContents;
    ReadFile readFile = new ReadFile();

    final Directory directory = await getApplicationDocumentsDirectory();
    late File file;

    if (selectedTribe == "terran") {
      file = File("${directory.path}/terran_tech_tree.json");
      techTreeContents = await json.decode(file.readAsStringSync());
    } else if (selectedTribe == "protoss") {
      file = File("${directory.path}/protoss_tech_tree.json");
      techTreeContents = await json.decode(file.readAsStringSync());
    } else {
      file = File("${directory.path}/zerg_tech_tree.json");
      techTreeContents = await json.decode(file.readAsStringSync());
    }

    techTreeContents.forEach((e, v) {
      Map<String, dynamic> content = {e: v};
      Map<String, dynamic> data = content[e];

      techTreeList.add(TechTreeModel.fromJson(data));
    });

    selectedtechTreeList = techTreeList
        .where((e) => e.name.contains(selectedTechTreeName))
        .toList();

    selectedTechTree = selectedtechTreeList[0];

    return Future.value(selectedTechTree);
  }

Why does the map_repository work, but why does the tech_tree_repository not work? OS Error: No push file or directory, erno = 2 is only available when tech_tree_repository is operated.

  1. Aset folder verification completed (no problem).
  2. File name resolution complete (no problem).

I'm in a hurry. Please help me.

a.ak
  • 576
  • 11
  • 23
97_HYUN
  • 63
  • 4
  • you can checkout this post : > https://stackoverflow.com/questions/57884286/os-error-no-such-file-or-directory-errno-2 – Amede Angel Aulerien Sep 06 '21 at 07:36
  • Actually, I've already used rootBundle, but my repository is to make a like button for the content, and then click on the like button and use selectedTechTreeJson. There is no update on the click of the button click. – 97_HYUN Sep 06 '21 at 07:41
  • I wonder why the map_repository runs without problems, but the tech_tree_repository does not. – 97_HYUN Sep 06 '21 at 07:43

0 Answers0