我有一个带有文本小部件和 ListView 的屏幕,当我尝试在 ListView 内滚动时,它不允许我滚动。
我的主体是 SingleChildScrollView,但它不为 ListView.builder 提供滚动视图。我试图将 ListView.build 包装在 Expanded 中,但没有成功。
class HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(
title: Text("MyBar"),
centerTitle: true,
),
body: SingleChildScrollView(child: Column(
children: <Widget>[
Text(
"Information"),
Container(
child: ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: widget.match.players.length,
itemBuilder: (context, index) {
return Column(
children: <Widget>[
Card(
child: ListTile(
leading: CircleAvatar(
radius: 30.0,
foregroundColor:
Theme.of(context).primaryColor,
backgroundColor: Colors.grey,
backgroundImage:
CachedNetworkImageProvider("url"),
),
title: new Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
new Text("Some text",
style: new TextStyle(
fontWeight: FontWeight.bold),
),
new Text(
"Some text",
style: new TextStyle(
fontWeight: FontWeight.bold),
),
]),
))
],
);
}))
],
)));}
}
任何人都知道如何使 listView.builder() 可滚动。