flutter


Reading the contents of a file into a String variable in Flutter


The problem is this: I have a .txt file that contains one line of text and I need to read that line into a String variable.
Most of the methods I found return either a Future or Future and I have no idea how to convert these types into Strings. Also, I'm not sure what I'm doing wrong with readAsStringSync because I get a "FileSystemExeption: Cannot open file (OS Error: No such file or directory)", even though I have referenced it in my pubspec.yaml
class LessonPage extends StatelessWidget { LessonPage({this.title, this.appBarColor, this.barTitleColor, this.fileName});
final String title;
final Color appBarColor;
final Color barTitleColor;
final String fileName;
#override
Widget build(BuildContext context) {
final file = new File(this.fileName);
return new Scaffold(
appBar: new AppBar(
title: new Text(
this.title,
style: new TextStyle(color: this.barTitleColor)
),
backgroundColor: this.appBarColor,
),
body: new Center(
child: new Text(
file.readAsStringSync(),
softWrap: true,
)
),
);

Related Links

How to get the smallest child in a box?
Replace initial Route in MaterialApp without animation?
How to make 1/3 of an image take up the full screen
How to make an Input's hintText disappear when the user starts typing?
PageStorage in Flutter - how does it work?
How to select Development team for iOS app created in Flutter
Sizing elements to percentage of screen width/height
Animated Widget only animates once
How can I dial the phone from Flutter?
How do I open a web browser (URL) from my Flutter code?
Unable to install Flutter on my windows machine
PageView with horizontal, non-filled children
How to navigate between flutter screen to native(android/ios) screens
Creating raw image from Widget or Canvas
The equivalent of wrap_content and match_parent in flutter?
Is there an AdMob or other ad service SDK for Flutter apps

Categories

HOME
lsf
printing
python-3.5
typeahead.js
windows-runtime
streaming
tsql
restsharp
android-bluetooth
netbeans-8
google-analytics-api
cross-domain
tin-can-api
coded-ui-tests
struts2-jquery
h2o
wav
superfish
research
avplayer
oracle-ucm
session-cookies
frequency
scrollbar
nservicebus
asp.net-mvc-5.2
nsmutableattributedstring
hp-alm
centroid
py4j
naturallyspeaking
azure-redis-cache
stylesheet
esri
sql-server-2014-express
plm
localdb
skyscanner
svgpanzoom
jtapi
petrel
vrtk
tweenmax
blockui
server-sent-events
vue2
partition
essbase
mdanalysis
ulimit
arm7
uifont
sql-mode
ammonite
asp.net-mvc-custom-filter
cakephp-2.3
hyperterm
ios-frameworks
vsvim
mutation
aplpy
skrollr
coldfusion-10
hjson
viennacl
equinox
maven-cargo
error-log
simperium
abort
windows-universal
javaw
nolio
bit.ly
cvs2git
boxapiv2
culture
opensc
ratingbar
imaging
pkcs#10
mouseenter
buildout
xcache
sugar.js
capitalize
uptime
file-structure
timestamp-with-timezone
code-structure
adaboost
intel-8080
mdi
demoscene
measure
nsindexset
seam-conversation
metaphone
plumtree

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App