esysberlin / esys-flutter-share

A Flutter plugin for sharing files & text with other applications.
Apache License 2.0
130 stars 147 forks source link

My path on rootBundle, just it works after Hot Reload be triggered( Android Studio) #75

Closed MAPJBR closed 4 years ago

MAPJBR commented 4 years ago

Describe the bug In my application, I just can right result, after triggered Hot Reload in IDE, on the contrary, the app throws an exception. error: Unable to load asset: /data/user/0/com.fluidobjects.quicktunemobile/app_flutter/statistic_info.csv

Future generateCSVandView()async{ // get data List data = list; List<List> csvData=[

['id','numberRegister','firstRegister', 'timer', 'sucess','error'], ...data.map((item)=>[item.id.toString(),item.numberRegister.toString(), item.fristRegister.toString(), item.timer, item.sucess.toString(), item.error.toString()]), ]; String csv = const ListToCsvConverter().convert(csvData); final String dir =(await getApplicationDocumentsDirectory()).path; final String path= '$dir/statistic_info.csv'; // create file final File file = File(path); // save csv string await file.writeAsString(csv); // share file.csv try{ ByteData byteData = await rootBundle.load(path); await Share.file("datas", "datas.csv", byteData.buffer.asUint8List(),"data/csv"); }catch(e){ print("error:$e"); } } Future_share()async{ await generateCSVandView(); } * * * * * * * * * * are happened to somebody?
MAPJBR commented 4 years ago

This is a Response 👍 https://stackoverflow.com/questions/58712261/unable-to-load-asset-file-the-app-created