So here's the solution. Basically, I looped through the document snapshot and saved the result in a list. Then, I set the list to the image.
Widget build(BuildContext context) {
var idx = 1;
return Container(
child: FutureBuilder(
future: getCarouselWidget(),
builder: (context, AsyncSnapshot snapshot) {
List<NetworkImage> list = new List<NetworkImage>();
if (snapshot.connectionState == ConnectionState.waiting) {
return new CircularProgressIndicator();
} else {
if (snapshot.hasError) {
return new Text("fetch error");
} else {
//Create for loop and store the urls in the list
for(int i = 0; i < snapshot.data[0].data.length; i++ ) {
debugPrint("Index is " + idx.toString());
list.add(NetworkImage(snapshot.data[0].data["img_"+idx.toString()]));
idx++;
}
return new Container(
height: 250.0,
child: new Carousel(
boxFit: BoxFit.cover,
images: list, <== Set the list here
autoplay: true,
dotSize: 4.0,
indicatorBgPadding: 4.0,
animationCurve: Curves.fastOutSlowIn,
animationDuration: Duration(milliseconds: 1000),
));
}
}
}),
);
try this:
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
class PostGetter extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return new Scaffold(
body: new Container(
child: new FutureBuilder(
future: Firestore.instance
.collection('post')
.where('article', isEqualTo: 'lpquVtoRNsu0vBLjNByS')
.getDocuments(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
if (snapshot.data != null) {
return new Column(
children: <Widget>[
new Expanded(
child: new ListView(
children: snapshot.data.documents
.map<Widget>((DocumentSnapshot document) {
return new ListTile(
title: new Text(document['comment']),
subtitle: new Text(document['author']),
);
}).toList(),
),
),
],
);
}
}else {
return new CircularProgressIndicator();
}
}),),
);
}
}
else should be on the snapshot.hasdata not on snapshot.data != null