Reputation: 789
I have a 500 MB text file in my assets folder. I want to read the content of this file (if possible line by line).
When I use "loadString()", just a couple of lines my file are printed (5 from 4000 lines). How can I read the whole content of the file?
Here is my code:
import 'dart:async' show Future;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show rootBundle;
class ReadText extends StatelessWidget {
@override
Widget build(BuildContext context) {
Future<void> loadAsset() async {
var myFileContent =
rootBundle.loadString('res/assets/raw/mydata.csv');
//Printing
return myFileContent.then(print);
}
loadAsset();
return Scaffold(
backgroundColor: Colors.orange,
appBar: AppBar(
title: Text("Read File"),
),
body: Center(
child: new Text("Empty page"),
),
);
}
}
Upvotes: 0
Views: 1336
Reputation: 10749
You are trying to print a large string in Console using the print() function. Which is not possible, flutter has its limit for large values to be printed in the console
You can try
debugPrint()
Function, but this too doesn’t guarantee whether your whole string (file) will be printed in the console. I’ll recommend you to print it on some Text widget to see it. I hope this helps
Upvotes: 1