GithubHelp home page GithubHelp logo

can't read file about dart_minecraft HOT 2 CLOSED

spnda avatar spnda commented on June 28, 2024
can't read file

from dart_minecraft.

Comments (2)

KaanBN avatar KaanBN commented on June 28, 2024

if anyone have the same problem as me this was my solution:

void _readFile() async 
    //I was able to extract Uint8List by doing like this.
    final ByteData data = await rootBundle.load('assets/files/dd.schem');
    //normally NbtReader.fromfile() already implemented but in my case reading bytes was not an option
   final nbtReader = NbtReader(data.buffer.asUint8List());
    // after that I was able to read file
    await nbtReader.read();
    NbtCompound<NbtTag>? rootNode = nbtReader.root;
    List<NbtTag>? block_types = rootNode?.getChildrenByName("Palette");
    print(block_types);
  }

from dart_minecraft.

spnda avatar spnda commented on June 28, 2024

Flutter does files a bit different depending on the platform, which is why packages like path_provider exist. NbtReader.fromFile internally just does File(path).readAsBytesSync(), which is relative to the app's working directory, which is not where the assets are stored by default afaik, though I haven't used Flutter with assets for a while. Though glad you fixed it using a different solution.

from dart_minecraft.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.