I'm using flutter to create an app. I'm trying to create a sort of box(using Positioned widget) where inside there will be a a scrollable list of widget. I need a Positioned widget to put in the right postion of stack my "box" widget. My problem is the list of object doesn't scroll. Any suggestion?
Widget build(BuildContext context) {
return FutureBuilder<List<SoccerMatch>>(
future: SoccerApi().getAllMatches(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Positioned(
top: _queryData.size.height * 0.50,
bottom: -_queryData.size.height * 0.6,
right: _queryData.size.width * 0.1,
left: _queryData.size.width * 0.1,
child: SingleChildScrollView(
physics: ScrollPhysics(),
child:
Column(
children: [
ListView.builder(
scrollDirection: Axis.vertical,
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: snapshot.data!.length,
itemBuilder: (context, index)
{
return matchTile(snapshot.data![index]);
},
),
],
),
),
);
} else {
return Center(
child: CircularProgressIndicator(),
);
}
},
);
}
CodePudding user response:
Just try to update your FutureBuilder with the following
FutureBuilder<List<SoccerMatch>>(
future: SoccerApi().getAllMatches(),
builder: (context, snapshot) {
print(snapshot);
if (!snapshot.hasData) {
return Center(
child: CircularProgressIndicator(),
);
}
if (snapshot.hasData) {
return Stack(
children: [
Positioned(
top: _queryData.size.height * 0.50,
bottom: -_queryData.size.height * 0.6,
right: _queryData.size.width * 0.1,
left: _queryData.size.width * 0.1,
child: SingleChildScrollView(
physics: ScrollPhysics(),
child:
Column(
children: (snapshot.data as List<SoccerMatch>).map((item) => matchTile(item)),
).toList()),
),
],
);
}
return SizedBox();
}
)
CodePudding user response:
You just need to replace your bottom with
height: _queryData.size.height * 0.5,