how to give my list view width to full screen width and how to make it auto scroll after few second ...
void scrollAfter(ScrollController scrollController, {int seconds}) {
Future.delayed(Duration(seconds: seconds), () {
var offset = 550.0;
var scrollDuration = Duration(seconds: 2);
scrollController.animateTo(offset,
duration: scrollDuration, curve: Curves.ease);
});
}
@override
Widget build(BuildContext context) {
var scrollController = ScrollController();
scrollAfter(scrollController, seconds: 2);
// TODO: implement build
return Container(child:
new StreamBuilder(
stream: Firestore.instance.collection('Top List').snapshots(),
builder: (BuildContext context,snapshot) {
if (!snapshot.hasData) return new Text("no");
var documentsLength = snapshot.data.documents.length;
return ListView.builder(itemCount: documentsLength,
scrollDirection: Axis.horizontal,
controller: scrollController,
shrinkWrap: true,
itemBuilder: (context, index) {
return buildlistItem((AllProduct.fromDocument(snapshot.data.documents[index])));
});
below my buildlistItem class form which i want to scroll ######################################################################################################################################################################################################################################################################
Widget buildlistItem(AllProduct alllist) {
return
new GestureDetector(
child: Container(
child: new Card(
elevation: 2.0,
margin: const EdgeInsets.all(5.0),
child: new Stack(
alignment: Alignment.center,
children: <Widget>[
new Hero(
tag: alllist.title,
child: new Image.network(alllist.backgroundImageUrl, fit: BoxFit.cover),
),
new Align(
child: new Container(
padding: const EdgeInsets.all(6.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(alllist.title,
style: new TextStyle(color: Colors.white,fontFamily: "ChelaOne-Regular")),
],
),
IconButton(onPressed: (){
},
icon: new Icon(Icons.add_shopping_cart,color: Colors.white,),
)
],
),
color: Colors.black.withOpacity(0.4),
),
alignment: Alignment.bottomCenter,
),
],
),
),
),
onTap: () {},
);
}
}