import 'package:flutter/services.dart' show rootBundle;
import 'dart:io';
import 'dart:convert';
loadAsset() async {
List<List<dynamic>> data = [];
List<String> fileData = [];
final myData = await File("assets/authentic.csv");
//final myData = await rootBundle.loadString('assets/authentic.json');
print(myData);
/*fileData = myData.split(",");
print("After splitting $fileData");*/
Stream<List> inputStream = myData.openRead();
inputStream.transform(utf8.decoder).transform(new LineSplitter()).listen(
(String line)
{
List row = line.split(",");
int QRCode = row[0];
String ProductName = row[1];
String ManufacturerName = row[2];
String MfdDate = row[3];
String ExpDate = row[4];
int Quantity = row[5];
print("Processed data : $QRCode, $ManufacturerName, $MfdDate");
},
onDone: () { print('File is now closed.'); },
onError: (e) { print(e.toString()); });
}
pubspec.yaml
assets:
- assets/authentic.csv
import 'package:path_provider/path_provider.dart';
Future<String> get localPath async {
final directory = await getApplicationDocumentsDirectory();
return directory.path;
}
Future<File> getFile(String name) async {
final path = await localPath;
return File('$path/$name');
}
Then, you would call getFile("assets/authenticate.csv") ... (I don't think you need the `/` before assets)--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.