to_csv 0.0.1 to_csv: ^0.0.1 copied to clipboard
This flutter package will help you to create a csv/excel file for your data in flutter framework application.
You can create a CSV/Excel file with much less code. Just pass a header row of type List
Features #
TODO: Download the CSV/EXCEL file of your data either on web or mobile.
How to use it? #
To use this plugin, add to_csv as a dependency in your pubspec.yaml file. And import this as in your dart file:
import 'package:to_csv/to_csv.dart' as exportCSV;
In your onPressed/onTap function (or wherever you like):
Create a list of Strings that will be the Header of your table or excel file.
List<String> header = [];
header.add('No.');
header.add('User Name');
header.add('Mobile');
header.add('ID Number');
Also create a two lists which contains your list of rows as List
List<List<String>> listOfLists = []; //Outter List which contains the data List
List<String> data1 = ['1','Bilal Saeed','1374934','912839812']; //Inner list which contains Data i.e Row
List<String> data2 = ['2','Ahmar','21341234','192834821']; //Inner list which contains Data i.e Row
List<String> data3 = []; //Inner list which contains Data i.e Row
Note: Length of elements present in Rows should be equal to the length of header list length Now add your data variables in listOfVisitor which is List<List
listOfLists.add(data1);
listOfLists.add(data2);
listOfLists.add(data3);
Finally pass header and listOfVisitors to the package function like this:
exportCSV.myCSV(header, listOfVisitors);
And your csvFile will be downloaded in no minutes. Open it on excel or in any other app and Enjoy!
Additional information #
If you like to contribute to this project, you are welcome. If you need to make any changes, please let me know and I'll help. And if you liked the package, don't forget to hit like button. If possible, buy me a coffee.