I have a list that comes in the form of future
Future<List<String>> _future;
List<String> showList = [];
String showCode;
Future<List<String>> getCode() async {
final show = await SharedPreferences.getInstance();
setState(() {
showList = show.getStringList('companyName');
});
print('here ${showList.toString()}');
return showList;
}
and when I print, my console will output like this
[Friends,Scrubs]
I'm trying to show this list to user by using Futurebuilder but my value is not show. I added it as a column in the container to be centered on the bottom.but only the CircularProgressIndicator() part is visible Any idea?
? Container(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
Column(
children: [
IconButton(
icon: Icon(Icons.close),
onPressed: () {
Navigator.pushNamed(
context, ShowScreen.routeName);
}),
Text(
'Please Select Show',
],
),
FutureBuilder(
future: _future,
builder: (context,
AsyncSnapshot<List<String>> snapshot) {
if (snapshot.hasData) {
return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (context, index) {
return Card(
elevation: 6.0,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Text(snapshot.data[index]),
],
),
));
});
} else{
return CircularProgressIndicator();
}
}),
],
),
),
)
looks like this, but its not show items
I set my data like this
else{
_showData = !_showData;
shows.forEach((element) {
showCode = element.showName;
showList.add(element.showName);
show.setStringList(
'showName', showList);
getCode();
})