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 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?
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

Categories

HOME
validation
demandware
orbeon
openshift-origin
bolt-cms
visual-studio-2012
jasypt
jfreechart
telerik
freebsd
drag
silverlight
light-inject
zebble
openmodelica
yii2-advanced-app
api-design
oracle11gr2
swig
dotnetbar
haml
azure-ad-graph-api
broker
urlrewriter.net
eonasdan-datetimepicker
listbox
rrd
meanjs
graphql-dotnet
arduino-esp8266
sql-server-2014-express
operator-keyword
plm
clappr
whatsapi
delete-row
bits
jsonstore
csr
azure-management-api
message-hub
btle
stateful
gradle-tooling-api
syncfusion
sdcc
msysgit
ase
powerpc
gulp-babel
adal.js
uifont
multistore
website-hosting
recurrence
jahia
webloadui
glumpy
tachyon
measurement-protocol
mit-scheme
jsbin
file-import
balsamiq
pygments
rras
duration
mongolab
hl7-v2
ane
autopy
phone-number
cbc-mode
bloodhound
mklink
citymaps
android-menu
dynamic-typing
magic-unipaas
mod-python
ccombobox
globbing
icon-fonts
locomotivejs
timestamp-with-timezone
51degrees
jscience
openfeint
hunchentoot
nhaml
greensoftware

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