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

Get Tap Position Relative to Widget
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?

Categories

HOME
clojure
web-services
whatsapp
music
azure-search
module
configuration
afp
weight
windows-runtime
middleware
mocha
jasypt
netbeans-8
http2
classloader
splunk
socrata
windows-10-desktop
sql-server-express
sonata-admin
rgb
imp
stackexchange-api
slowcheetah
silk-performer
gitlab-ci-runner
jmeter-plugins
jet
missingmethodexception
mouseevent
ssms-2014
sax
burp
shape
azure-redis-cache
physics
android-button
f2py
expression-trees
python-behave
bluebird
azure-api-apps
seh
draggable
symfony-process
psychopy
rating
gradle-tooling-api
nexus-5
using
php-deployer
dependency-management
simplesamlphp
sharpziplib
gcc4.8
sshd
zbar
zenity
itamae
hard-drive-failure
ultratree
tealeaf
jongo
main-activity
cucumber-java
multiple-files
wand
materialdrawer
symbian
avalonedit
devenv
sketching
react-rails
centering
java-client
puppet-enterprise
android-tablelayout
information-schema
sqlhelper
iphone-privateapi
bonecp
xacml3
ituneslibrary
disk-io
windows-phone-7.1
junit-runner
pydatalog
rte
webcal
jquery-data
slimbox
icon-fonts
libavg
vim-fugitive
program-files
f2c
emacs-ecb
jdic
jboss-cache
keylogger
ryz
net-ssh
contracts
docking

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