Home > database >  how can I import csv file in flutter in 2.5?
how can I import csv file in flutter in 2.5?

Time:10-04

**Kindly share the link of code or code and I m trying but I m not found anything good for importing CSV file **

please tell me which library I use

CodePudding user response:

so you can use Flutter csv library
import 'package:file_picker/file_picker.dart'; import 'package:csv/csv.dart';

pickFile() async {
   FilePickerResult result = await FilePicker.platform.pickFiles();
   if (result != null) {
     PlatformFile file = result.files.first;

     final input = new File(file.path).openRead();
     final fields = await input
         .transform(utf8.decoder)
         .transform(new CsvToListConverter())
         .toList();

     print(fields);
   }
 }
  • Related