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

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
How can I access the contents of a StatefulWidget's State during a unit test?
How can I tightly wrap a Column of widgets inside a Card?
What's the reason for “async” in testWidgets methods?
How can I inherit a StatefulWidget's State?
Why is this icon being clipped?
IconButton calling setState during onPressed shows no ripple effect
How can I test a TextPainter?

Categories

HOME
opencv
redirect
sharepoint-2013
configuration
jsonschema
bootstrap-selectpicker
active-directory
wikipedia-api
splunk
entity
identifier
wso2-das
research
eloqua
openmodelica
editor
calabash-android
api-design
pcap
atg
centroid
cadvisor
zos
ratchet-2
addthis
structure
codewarrior
apache-commons-httpclient
localdb
evercookie
jdk1.6
increment
ubuntu-server
zipline
bem
sagepay
internet-explorer-10
wso2iot
worldpay
polymer-cli
qmake
default-browser
android-calendar
clientscript
wrk
ctl
canopen
biological-neural-network
manifoldcf
post-increment
heritrix
duration
ota
strace
wand
cng
crosswalk
selectsinglenode
smarty2
mks
chatjs
tab-delimited
publish-actions
zeroclipboard
jqgrid-php
simpleaudioengine
git-gui
sparc
route-me
argumentexception
google-goggles
memento
12factor
timespan
oncreate
ribbon-control
payment-services
renderaction
pinging
anemic-domain-model
variable-names

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