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

Flutter Focus App That Is Not In Foreground
How to center the title of an appbar
Using TextField throws “No Material widget found” error
Hide Android Status Bar On Flutter App
GestureDetector within TabBarView - nested scrolling?
Flutter: Move dialog up to make room for soft keyboard?
How to create a hyperlink in Flutter widget?
Adding a splash screen to Flutter apps
How to change the application icon on Flutter?
How can I target status bar color or opacity in a Flutter app?
How do I supply an initial value to a text field?
How to control sizing behaviour to be based on parent or child?
Programmatically scrolling to the end of a ListView
Get Tap Position Relative to Widget
How to get the smallest child in a box?
Replace initial Route in MaterialApp without animation?

Categories

HOME
flutter
ssl
svg
google-search
elf
android-activity
watson
jsessionid
twitter-digits
pyusb
r-caret
predictionio
push
numericupdown
countdown
javers
swig
azure-ad-graph-api
missingmethodexception
py4j
precision
iteration
apache-httpcomponents
listbox
opensuse
gecko
scatter-plot
sqlite.swift
blockui
server-sent-events
imagemapster
outlook-vba
runge-kutta
linechart
weebly
php-5.5
formatdatetime
tern
angularjs-routing
xargs
couchbase-lite
slt
android-calendar
stroke
attributerouting
typesetting
tryton
sqlite-net
tachyon
android-chips
amazon-dynamodb-streams
turnjs
file-management
rras
groups
win32com
egl
aldryn
wchar-t
oboe.js
kindlegen
axlsx
voting
devenv
bloodhound
fastparse
windows-universal
generalization
kue
computer-science-theory
opensc
brooklyn
imaging
publish-actions
eventmachine
team-explorer-everywhere
jquery-backstretch
yourls
execcommand
micro-orm
scrollpane
gdb-python
angularjs-module
neventstore
sizzle
slimbox
12factor
symfony-2.2
blackberry-cascades
applaud
squirrelmail
maven-bundle-plugin
self-organizing-maps
ruby-1.9.2
combinators
machine.config
hunchentoot
apache-config
ryz
help-authoring
palm-pre
web-based

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