0

I used path-provider and open-file for open docx file from asset which worked fine without conflict in my project, then I needed to change some text in docx file. After changing it gave me an error like Unable to open the document, decoding error

here is my open file method code

onPressed: () async {
    Future<File> openFileFromAsset() async {
        Directory tempDir = await getTemporaryDirectory();
        File tempFile = File('${tempDir.path}/$fileName.docx');
        ByteData bd = await rootBundle.load(assetName);
        await tempFile.writeAsBytes(bd.buffer.asUint8List(), flush: true);
        return tempFile;
  }
  openFileFromAsset().then((file){OpenFile.open(file.path);});
},

I want to fix the error

0 Answers0