There is plenty example of CSV to list for flutter apps, I'm facing issues with flutter web and the conversion of the file.
Some CSV aren't working as desired, I guess that it's a formatting issue Here is the converting function when a user upload a file
Future _openFileExplorer() async {
FilePickerResult? result = await FilePicker.platform.pickFiles(
allowMultiple: false,
withData: true,
type: FileType.custom,
allowedExtensions: ['csv']);
if (result != null) {
//decode bytes back to utf8
final bytes = utf8.decode((result.files.first.bytes)!.toList());
setState(() {
//from the csv plugin
employeeData = CsvToListConverter().convert(bytes);
});
}
}
Working CSV file conversion
Not working csv file conversion, the structure isn't the same, it's a big chunck
I did a complete repo of the project if you want to try, added some photos in the README,
You should add
eol: "\r\n",fieldDelimiter: ","
toCsvToListConverter()
. your code will be like this: