I would like to upload csv file in Flutter. I am using FileUploadInputElement for file browsing. The problem I issue is how to convert the data to csv format.
This is currently the code I am using:
class _GenesTableTabState extends State<GenesTableTab> {
Uint8List uploadedCsv;
String option1Text;
_startFilePicker() async {
InputElement uploadInput = FileUploadInputElement();
uploadInput.click();
uploadInput.onChange.listen((e) {
// read file content as dataURL
final files = uploadInput.files;
if (files.length == 1) {
final file = files[0];
FileReader reader = FileReader();
reader.onLoadEnd.listen((e) {
setState(() {
uploadedCsv = Base64Decoder()
.convert(reader.result.toString().split(",").last);
});
});
reader.onError.listen((fileEvent) {
setState(() {
option1Text = "Some Error occured while reading the file";
});
});
reader.readAsDataUrl(file);
}
});
}
I don't know how to handle uploadedCsv field after the decoding.

