我正在尝试添加一个具有 2 列和 3 行的 gridview。我的问题是,当我尝试将它添加到我的行时,它会使整个页面消失。这是我的代码
class HomePage extends StatelessWidget{
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(
elevation: 0.5,
title: Text("Home", style: TextStyle(fontSize: 15, color: Colors.black45)),
centerTitle: true,
backgroundColor: Colors.white,
),
body: SingleChildScrollView(
child: Column(
children: <Widget>[
new Container(
margin: const EdgeInsets.all(25),
child: Text("Shop Category", style: new TextStyle(fontSize: 18, color: Colors.black, fontFamily: 'Raleway'),textAlign: TextAlign.left,),
),
new GridView.count(
primary: true,
crossAxisCount: 2,
children: <Widget>[
new Image.asset('assets/images/meat.jpg')
],
)
],
)
),
);
}
Run Code Online (Sandbox Code Playgroud)
die*_*per 19
只需将该shrinkWrap属性添加到您的GridView
new GridView.count(
shrinkWrap: true,
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5351 次 |
| 最近记录: |