Flutter:只有 gridview 是可滚动的
Flutter: Only gridview is scrollable
我试图让我的整个页面在我的应用程序上滚动,但由于某些未知原因,只有网格视图在滚动,谁能帮我弄清楚为什么会这样?
百万感谢。
这是我的代码:
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(20.0),
child: Column(
children: <Widget>[
Container(
width: double.infinity,
height: SizeConfig.screenHeight / 2.5,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/food2.png'),
fit: BoxFit.cover)),
),
const Align(
alignment: Alignment.centerLeft,
child: Text(
"Donation Cards",
style: TextStyle(
fontFamily: 'Quicksand',
fontSize: 31,
color: Colors.black,
fontWeight: FontWeight.w300,
),
),
),
const Divider(color: Colors.black38),
const SizedBox(
height: 20,
),
Expanded(
child: GridView.count(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
children: _listItem
.map((item) => Card(
color: Colors.transparent,
elevation: 0,
//child: GestureDetector(
child: GestureDetector(
onTap: () => Navigator.pushNamed(context, item.route),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
image: DecorationImage(
image: AssetImage(item.image),
fit: BoxFit.cover)),
)),
))
.toList(),
))
],
),
);
}
}
再次感谢!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
用 singlechildscrollview 换行并给 gridview physics:NeverScrollableScrollPhysics()
我试图让我的整个页面在我的应用程序上滚动,但由于某些未知原因,只有网格视图在滚动,谁能帮我弄清楚为什么会这样? 百万感谢。
这是我的代码:
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(20.0),
child: Column(
children: <Widget>[
Container(
width: double.infinity,
height: SizeConfig.screenHeight / 2.5,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/food2.png'),
fit: BoxFit.cover)),
),
const Align(
alignment: Alignment.centerLeft,
child: Text(
"Donation Cards",
style: TextStyle(
fontFamily: 'Quicksand',
fontSize: 31,
color: Colors.black,
fontWeight: FontWeight.w300,
),
),
),
const Divider(color: Colors.black38),
const SizedBox(
height: 20,
),
Expanded(
child: GridView.count(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
children: _listItem
.map((item) => Card(
color: Colors.transparent,
elevation: 0,
//child: GestureDetector(
child: GestureDetector(
onTap: () => Navigator.pushNamed(context, item.route),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
image: DecorationImage(
image: AssetImage(item.image),
fit: BoxFit.cover)),
)),
))
.toList(),
))
],
),
);
}
}
再次感谢!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
用 singlechildscrollview 换行并给 gridview physics:NeverScrollableScrollPhysics()